3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function gen1() { echo "Gen1\n"; $a = yield 1; echo "Resumed. a is $a\n"; } function gen2() { echo "Gen2\n"; $b = yield 2; echo "Resumed. b is $b\n"; } function yf() { yield from gen1(); echo "Between\n"; yield from gen2(); } $g = yf(); echo "Autoprime"; var_dump($g->current()); echo "Sending\n"; var_dump($g->send(42)); echo "Done\n";
Output for 7.0.0 - 7.2.0
AutoprimeGen1 int(1) Sending Resumed. a is 42 Between Gen2 int(2) Done
Output for 5.4.0 - 5.6.21
Parse error: syntax error, unexpected '1' (T_LNUMBER) in /in/i7Sbi on line 5
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected T_LNUMBER in /in/i7Sbi on line 5
Process exited with code 255.