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; } } echo foo2($arr); echo foo2($arr);
based on hoq1M
Output for 7.1.0 - 7.2.0
Recoverable fatal error: Object of class Generator could not be converted to string in /in/Is0AS 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/Is0AS on line 23
Process exited with code 255.
Output for 5.4.11 - 5.4.45
Parse error: syntax error, unexpected '$el' (T_VARIABLE) in /in/Is0AS on line 19
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected T_VARIABLE in /in/Is0AS on line 19
Process exited with code 255.