3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ping_pong() { for ($i = 1; $i <= 10; $i++) { echo 'a' . $i . PHP_EOL; $val = (yield $i); echo 'b' . $i . ':' . $val PHP_EOL; //echo 'ping: ' . $val . PHP_EOL; } } $generator = ping_pong(); foreach ($generator as $value) { echo 'c' . $value . PHP_EOL; //echo 'pong: ' . $generator->send($value) . PHP_EOL; }
Output for 5.4.0 - 5.4.25
Parse error: syntax error, unexpected '$i' (T_VARIABLE) in /in/gLFoH on line 8
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_VARIABLE in /in/gLFoH on line 8
Process exited with code 255.

preferences:
177.14 ms | 1394 KiB | 62 Q