3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php (function() { $iterator = $this->getIterator(); foreach ($iterator as $value) { var_dump($value); } var_dump($iterator->getReturn()); })->call(new class implements IteratorAggregate { public function getIterator() { yield 0; yield from [1,2,3,4]; return 5; } });
based on fajuM
Output for 7.0.0 - 7.2.0
int(0) int(1) int(2) int(3) int(4) int(5)
Output for 5.4.0 - 5.6.28
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /in/IgsiV on line 9
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/IgsiV on line 9
Process exited with code 255.