3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function createGen() { for ($i = 0; $i< 10; $i++) { $a = (yield $i); if ($a == 'stop') { return; } } } $gen = createGen(); foreach ($gen as $value) { if ($value === 5) { $value->send('stop'); } echo $value . PHP_EOL; }
based on 225Vs
Output for 7.0.0 - 7.2.0
0 1 2 3 4 Fatal error: Uncaught Error: Call to a member function send() on integer in /in/Rg4Ie:18 Stack trace: #0 {main} thrown in /in/Rg4Ie on line 18
Process exited with code 255.
Output for 5.6.8 - 5.6.28
0 1 2 3 4 Fatal error: Call to a member function send() on integer in /in/Rg4Ie on line 18
Process exited with code 255.
Output for 5.5.24 - 5.5.35
0 1 2 3 4 Fatal error: Call to a member function send() on a non-object in /in/Rg4Ie on line 18
Process exited with code 255.
Output for 5.4.10 - 5.4.45
Parse error: syntax error, unexpected '$i' (T_VARIABLE) in /in/Rg4Ie on line 6
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected T_VARIABLE in /in/Rg4Ie on line 6
Process exited with code 255.