3v4l.org

run code in 300+ PHP versions simultaneously
<?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.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.19, 8.3.0 - 8.3.7
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 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 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.

preferences:
161.32 ms | 402 KiB | 185 Q