3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $list = [2, 4, 6]; $d = function(array $list){ foreach ($list as $x) yield $x * $x; }; foreach ($d() as $e) { echo $e . "\n"; }
based on T0AiK
Output for 7.1.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function {closure}(), 0 passed in /in/HuQbg on line 9 and exactly 1 expected in /in/HuQbg:5 Stack trace: #0 /in/HuQbg(9): {closure}() #1 {main} thrown in /in/HuQbg on line 5
Process exited with code 255.
Output for 7.0.0 - 7.0.14
Fatal error: Uncaught TypeError: Argument 1 passed to {closure}() must be of the type array, none given, called in /in/HuQbg on line 9 and defined in /in/HuQbg:5 Stack trace: #0 /in/HuQbg(9): {closure}() #1 {main} thrown in /in/HuQbg on line 5
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Warning: __invoke() expects exactly 1 parameter, 0 given in /in/HuQbg on line 7 Catchable fatal error: Argument 1 passed to __invoke() must be an instance of array, undefined variable given in /in/HuQbg on line 7
Process exited with code 255.
Output for 5.5.24 - 5.6.28
Catchable fatal error: Argument 1 passed to {closure}() must be of the type array, none given in /in/HuQbg on line 5
Process exited with code 255.
Output for 5.4.0 - 5.4.45
Parse error: syntax error, unexpected '$x' (T_VARIABLE) in /in/HuQbg on line 6
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/HuQbg on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/HuQbg on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/HuQbg on line 3
Process exited with code 255.