3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function doStuff() { $last = 0; $current = 1; echo "out l, c: $last, $current\n"; yield 1; while ($current < 1000) { echo "start l, c: $last, $current\n"; $current = $last + $current; $last = $current - $last; echo "before l, c: $last, $current\n"; yield $current; echo "after l, c: $last, $current\n"; } } foreach(doStuff() as $num) $num; ?>
based on pc34l
Output for 5.5.24 - 7.1.0
out l, c: 0, 1 start l, c: 0, 1 before l, c: 1, 1 after l, c: 1, 1 start l, c: 1, 1 before l, c: 1, 2 after l, c: 1, 2 start l, c: 1, 2 before l, c: 2, 3 after l, c: 2, 3 start l, c: 2, 3 before l, c: 3, 5 after l, c: 3, 5 start l, c: 3, 5 before l, c: 5, 8 after l, c: 5, 8 start l, c: 5, 8 before l, c: 8, 13 after l, c: 8, 13 start l, c: 8, 13 before l, c: 13, 21 after l, c: 13, 21 start l, c: 13, 21 before l, c: 21, 34 after l, c: 21, 34 start l, c: 21, 34 before l, c: 34, 55 after l, c: 34, 55 start l, c: 34, 55 before l, c: 55, 89 after l, c: 55, 89 start l, c: 55, 89 before l, c: 89, 144 after l, c: 89, 144 start l, c: 89, 144 before l, c: 144, 233 after l, c: 144, 233 start l, c: 144, 233 before l, c: 233, 377 after l, c: 233, 377 start l, c: 233, 377 before l, c: 377, 610 after l, c: 377, 610 start l, c: 377, 610 before l, c: 610, 987 after l, c: 610, 987 start l, c: 610, 987 before l, c: 987, 1597 after l, c: 987, 1597
Output for 5.4.0 - 5.4.45
Parse error: syntax error, unexpected '1' (T_LNUMBER) in /in/RZAC9 on line 7
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected T_LNUMBER in /in/RZAC9 on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_LNUMBER in /in/RZAC9 on line 7
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/RZAC9 on line 7
Process exited with code 255.