3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $func = function(array $a, $b){ echo implode(' ', func_get_args()); }; $closure = &$func; $reflection = new ReflectionFunction($closure); $arguments = $reflection->getParameters(); if($arguments && $arguments[0]->isArray()){ echo 'Giving array. Result: '; call_user_func($closure, ['a' => 5, 'b' => 10]); } else { echo 'Giving individuals. Result: '; call_user_func($closure, 5, 10); }
based on XUXRG
Output for 7.1.0 - 7.2.0
Giving array. Result: Fatal error: Uncaught ArgumentCountError: Too few arguments to function {closure}(), 1 passed in /in/WGmZZ on line 11 and exactly 2 expected in /in/WGmZZ:3 Stack trace: #0 /in/WGmZZ(11): {closure}(Array) #1 {main} thrown in /in/WGmZZ on line 3
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Giving array. Result: Warning: Missing argument 2 for {closure}(), called in /in/WGmZZ on line 11 and defined in /in/WGmZZ on line 3 Notice: Array to string conversion in /in/WGmZZ on line 3 Array
Output for 5.4.2 - 5.6.28
Giving array. Result: Warning: Missing argument 2 for {closure}() in /in/WGmZZ on line 3 Notice: Array to string conversion in /in/WGmZZ on line 3 Array
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/WGmZZ on line 11
Process exited with code 255.