3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo() { echo 'In generator func foo',"\n"; for ($i = 11; $i < 14; $i++) { $string=(yield $i); if (isset($string)) { echo "String is $string,"\n"; } } echo 'generator done and closed.',"\n"; return; } $generator = foo(); foreach ($generator as $value) { echo "Value is $value\n"; if ($value == 13) { $generator->send('Hello World'); } }
Output for 5.4.0 - 5.4.22
Parse error: syntax error, unexpected '$i' (T_VARIABLE) in /in/0R2O6 on line 6
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_VARIABLE in /in/0R2O6 on line 6
Process exited with code 255.

preferences:
181.82 ms | 1395 KiB | 58 Q