3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function del1() { yield 1; return 'hi'; } function del2() { yield 2; } function g_master() { $x = yield from del1(); echo "lv ", $x, "\n"; yield 3; $y = yield from del2(); echo "lv2 ", $y, "\n"; yield 4; return 5; } foreach (g_master() as $x) { echo $x, "\n"; }
Output for 7.0.0 - 7.2.0
1 lv hi 3 2 lv2 4
Output for 5.5.24 - 5.6.28
Fatal error: Generators cannot return values using "return" in /in/Eb1PT on line 5
Process exited with code 255.
Output for 5.4.2 - 5.4.45
Parse error: syntax error, unexpected '1' (T_LNUMBER) in /in/Eb1PT on line 4
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected T_LNUMBER in /in/Eb1PT on line 4
Process exited with code 255.