3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function iterator() { for ($i = 1; $i <= 10; $i++) { echo 'pre it:' . $i . PHP_EOL;continue; $res = yield ($i); //var_dump($res); } } $generator = iterator(); //$generator->raise('test'); //$generator->getOrigFuncName(); //$generator->getCalledClass(); foreach ($generator as $val){ //echo $val . PHP_EOL; //$generator->send('hi'); }
based on EXS0C
Output for 4.3.11, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
pre it:1 pre it:2 pre it:3 pre it:4 pre it:5 pre it:6 pre it:7 pre it:8 pre it:9 pre it:10
Output for 5.5.24 - 5.6.28
Parse error: syntax error, unexpected '(' in /in/q108b on line 8
Process exited with code 255.
Output for 4.3.10, 4.4.0 - 4.4.9, 5.0.2 - 5.4.45
pre it:1 pre it:2 pre it:3 pre it:4 pre it:5 pre it:6 pre it:7 pre it:8 pre it:9 pre it:10 Warning: Invalid argument supplied for foreach() in /in/q108b on line 17
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/q108b on line 7 pre it:1PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/q108b on line 7 pre it:2PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/q108b on line 7 pre it:3PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/q108b on line 7 pre it:4PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/q108b on line 7 pre it:5PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/q108b on line 7 pre it:6PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/q108b on line 7 pre it:7PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/q108b on line 7 pre it:8PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/q108b on line 7 pre it:9PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/q108b on line 7 pre it:10PHP_EOL Warning: Invalid argument supplied for foreach() in /in/q108b on line 17