3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function gen1() { $x = yield 1; $y = yield 2; var_dump($x + $y); yield 3; } function wat($iter) { var_dump($iter->valid()); } function yf($iter) { $x = yield from $iter; var_dump($x); } // wat(gen1()); // wat([4, 5, 6]); $g = yf([4, 5, 6]); // $g = yf(gen1()); var_dump($g->current()); $g->send(10); var_dump($g->current()); $g->next(); var_dump($g->current());
based on s5QJH
Output for 7.0.0 - 7.2.0
int(4) int(5) int(6)
Output for 5.4.0 - 5.6.28
Parse error: syntax error, unexpected '1' (T_LNUMBER) in /in/2Lc2I on line 4
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected T_LNUMBER in /in/2Lc2I on line 4
Process exited with code 255.