3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function generator() { $i=0; echo "Generating value...\r\n"; yield $i; $i++; echo "Incremeting \r\n"; } $x = generator(); for ($i=0;$i<10;$i++) { echo "Getting value"; echo $x; }
based on aQmVv
Output for 7.1.0 - 7.2.8
Getting value Recoverable fatal error: Object of class Generator could not be converted to string in /in/TpFGC on line 15
Process exited with code 255.
Output for 5.5.24 - 7.0.20
Getting value Catchable fatal error: Object of class Generator could not be converted to string in /in/TpFGC on line 15
Process exited with code 255.
Output for 5.4.10 - 5.4.45
Parse error: syntax error, unexpected '$i' (T_VARIABLE) in /in/TpFGC on line 7
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected T_VARIABLE in /in/TpFGC on line 7
Process exited with code 255.