多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ## 实例 ``` interface animal { public function say(); } class People implements animal { public function say(){ echo "say People \n"; } } class Dog implements animal { public function say(){ echo "say Dog \n"; } } class Cat implements animal{ public function say() { echo "say Cat \n"; } } $p= new People(); $d= new Dog(); $c= new Cat(); $obj = new SplObjectStorage(); $obj->attach($p); $obj->attach($d); $obj->attach($c); $obj->detach($c); echo $obj->count(); //2 var_dump($obj->contains($p)); //true 是否包含 $a var_dump($obj->valid()); //true //rewind 使 $obj 可反复遍历 $obj->rewind(); while($obj->valid()){ $current = $obj->current(); $current->say(); $obj->next(); } //say People //say Dog ```