3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function gen_one_to_three() { $y=[1,4,7]; foreach ($y as $x) { echo $x; if($x > 1): yield $x; } } $generator = gen_one_to_three(); foreach ($generator as $value) { echo "$value\n"; }
Output for 5.4.0 - 5.4.22
Parse error: syntax error, unexpected '$x' (T_VARIABLE) in /in/SK9fn on line 8
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected '[' in /in/SK9fn on line 3
Process exited with code 255.