0006デフォルトの名無しさん (ワッチョイ 76ef-C0zt)
2018/11/30(金) 07:14:24.64ID: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部ですか?