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; //$res = yield $i; //var_dump($res); } } $generator = iterator(); //foreach ($generator as $val) //{ // echo $val . PHP_EOL; // $generator->send('hi'); //}
based on WUi8o
Output for 4.3.10 - 4.4.1, 4.4.3 - 4.4.9, 5.0.2 - 5.0.5, 5.1.1, 5.1.3 - 5.1.4, 5.1.6 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
pre it1 pre it2 pre it3 pre it4 pre it5 pre it6 pre it7 pre it8 pre it9 pre it10
Output for 4.4.2, 5.1.2, 5.1.5
//}pre it1 pre it2 pre it3 pre it4 pre it5 pre it6 pre it7 pre it8 pre it9 pre it10
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/uiO5s on line 18
Process exited with code 255.
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/uiO5s on line 7 pre it1PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/uiO5s on line 7 pre it2PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/uiO5s on line 7 pre it3PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/uiO5s on line 7 pre it4PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/uiO5s on line 7 pre it5PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/uiO5s on line 7 pre it6PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/uiO5s on line 7 pre it7PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/uiO5s on line 7 pre it8PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/uiO5s on line 7 pre it9PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/uiO5s on line 7 pre it10PHP_EOL