3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function gen1() { $x = yield 1; $y = yield 2; var_dump("==="); var_dump($x + $y); var_dump("==="); 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()); $g->next(); var_dump($g->current());
based on 7GKi7
Output for 7.0.0 - 7.2.0
int(1) int(2) string(3) "===" int(10) string(3) "===" int(3) string(6) "== ==" NULL
Output for 5.4.0 - 5.6.28
Parse error: syntax error, unexpected '1' (T_LNUMBER) in /in/00Mad 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/00Mad on line 4
Process exited with code 255.