3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo implements IteratorAggregate { public function getIterator(){ return new class implements IteratorAggregate{ public function getIterator(){ yield from [1, 2, 3]; } }; } } function iterator(Iterable $iterable): Iterator{ return $iterable instanceof Iterator ? $iterable : iterator($iterable->getIterator()); } $foo = new foo; $iterator = iterator($foo->getIterator()); foreach($iterator as $a) echo $a;

This is an error 404

There are `0` results


preferences:
158.02 ms | 1403 KiB | 7 Q