3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function bar($x) { yield from $x; } /* Twice a Generator from bar() using yield from on $gen */ $it = [1, 2, 3, 4]; $gens[] = bar($it); $gens[] = bar($it); $i = 0; do { foreach ($gens as $g) { var_dump($g->current()); $g->next(); } $i++; } while($gens[0]->valid()); var_dump($gens[1]->valid());
Output for 7.0.0 - 7.2.0
int(1) int(1) int(2) int(2) int(3) int(3) int(4) int(4) bool(false)
Output for 5.5.24 - 5.6.28
Parse error: syntax error, unexpected '$x' (T_VARIABLE) in /in/7g6Bm on line 4
Process exited with code 255.
Output for 5.4.9 - 5.4.45
Parse error: syntax error, unexpected 'from' (T_STRING) in /in/7g6Bm on line 4
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/7g6Bm on line 4
Process exited with code 255.