3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function foo() { echo 'In generator func foo',"\n"; for ($i = 1; $i <= 4; $i++) { $string=(yield $i); if ($string == 'Hello World') { yield $string,"\n"; } } echo 'generator done and closed.',"\n"; return; } $generator = foo(); foreach ($generator as $value) { if ($value == 2) { $generator->send('Hello World'); } echo "$value\n"; }
Output for 5.4.0 - 5.4.22
Parse error: syntax error, unexpected '$i' (T_VARIABLE) in /in/CbbAl 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/CbbAl on line 6
Process exited with code 255.