- 【PHP】下らねぇ質問はここに書き込みやがれ 10
6 :デフォルトの名無しさん (ワッチョイ 76ef-C0zt)[sage]:2018/11/30(金) 07:14:24.64 ID:EXc3g5vT0 - ↑誤爆すみません。↓よろしくお願いします。
---Friendlist.php--- <?php class FriendList implements IteratorAggregate{ private $list=[]; public function getIterator():Traversable{ return new ArrayIterator($this->list); } public function add($p){ $this->list[]=$p; } これを他のクラスでインスタンス化して、foreachで反復処理する場合、 $friendl=new Friendlist(); foreach($friendl as $value){ } どの部分でFriendlist.phpのgetIterator()が読み込まれるのでしょうか? foreact部ですか?
|