3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class FooManager { public function test($foos) { foreach ($foos as $item) { yield from $item->test(); } } } class Foo { public function test() { return $this->getGenerator(range(0, 10)); } public function getGenerator(array $items) { foreach ($items as $item) { yield $item; } } } $f = new FooManager; $foos = [new Foo,new Foo,new Foo,new Foo]; foreach ($f->test($foos) as $int) { var_dump($int); }
based on Ckgt7
Output for 7.0.0 - 7.2.0
int(0) int(1) int(2) int(3) int(4) int(5) int(6) int(7) int(8) int(9) int(10) int(0) int(1) int(2) int(3) int(4) int(5) int(6) int(7) int(8) int(9) int(10) int(0) int(1) int(2) int(3) int(4) int(5) int(6) int(7) int(8) int(9) int(10) int(0) int(1) int(2) int(3) int(4) int(5) int(6) int(7) int(8) int(9) int(10)
Output for 5.5.24 - 5.6.28
Parse error: syntax error, unexpected '$item' (T_VARIABLE) in /in/30Ep8 on line 7
Process exited with code 255.
Output for 5.4.11 - 5.4.45
Parse error: syntax error, unexpected 'from' (T_STRING) in /in/30Ep8 on line 7
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/30Ep8 on line 7
Process exited with code 255.