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); }

preferences:
43.74 ms | 402 KiB | 5 Q