3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $arr = array(1,2,3); function foo($arr) { $result = array(); foreach($arr as $el) { $result[] = $el * 2; } return $result; } function foo2($arr) { $result = array(); foreach($arr as $el) { yield ($el * 2); } } echo foo2($arr); echo foo2($arr);
based on uD0FN
Output for 7.1.0 - 7.2.0
Recoverable fatal error: Object of class Generator could not be converted to string in /in/hoq1M on line 23
Process exited with code 255.
Output for 5.5.24 - 7.0.20
Catchable fatal error: Object of class Generator could not be converted to string in /in/hoq1M on line 23
Process exited with code 255.
Output for 5.3.21 - 5.4.45
Fatal error: Call to undefined function yield() in /in/hoq1M on line 19
Process exited with code 255.