3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen_one_to_three() { $y=[1,4,7]; foreach ($y as $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/PLGOE on line 8
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected '[' in /in/PLGOE on line 3
Process exited with code 255.

preferences:
202.95 ms | 1395 KiB | 58 Q