3v4l.org

run code in 300+ PHP versions simultaneously
<?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); }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Deprecated: Method ReflectionParameter::isArray() is deprecated in /in/WGmZZ on line 9 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 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Deprecated: Method ReflectionParameter::isArray() is deprecated in /in/WGmZZ on line 9 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.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
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.4.45, 5.5.24 - 5.5.35, 5.6.7 - 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

preferences:
215.69 ms | 402 KiB | 272 Q