3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen_one_to_three() { for ($i = 1; $i <= 10; $i++) { if (($val = (yield $i)) !== null { echo 'source: ' . $val . PHP_EOL; } } } $generator = gen_one_to_three(); foreach ($generator as $value) { $val = $generator->send($value); echo 'iteration: ' . $val . PHP_EOL; }
Output for 5.4.0 - 5.4.25
Parse error: syntax error, unexpected '$i' (T_VARIABLE) in /in/cJHpc on line 6
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_VARIABLE in /in/cJHpc on line 6
Process exited with code 255.

preferences:
184.42 ms | 1394 KiB | 62 Q