3v4l.org

run code in 300+ PHP versions simultaneously
<?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'); }
Output for 4.3.11, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
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.5.35, 5.6.8 - 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.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 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

preferences:
260.72 ms | 404 KiB | 312 Q