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(); echo foo2();
Output for 7.1.0 - 7.2.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function foo2(), 0 passed in /in/uD0FN on line 23 and exactly 1 expected in /in/uD0FN:16 Stack trace: #0 /in/uD0FN(23): foo2() #1 {main} thrown in /in/uD0FN on line 16
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/uD0FN on line 23
Process exited with code 255.
Output for 5.3.21 - 5.4.45
Warning: Missing argument 1 for foo2(), called in /in/uD0FN on line 23 and defined in /in/uD0FN on line 16 Notice: Undefined variable: arr in /in/uD0FN on line 18 Warning: Invalid argument supplied for foreach() in /in/uD0FN on line 18 Warning: Missing argument 1 for foo2(), called in /in/uD0FN on line 24 and defined in /in/uD0FN on line 16 Notice: Undefined variable: arr in /in/uD0FN on line 18 Warning: Invalid argument supplied for foreach() in /in/uD0FN on line 18