3v4l.org

run code in 300+ PHP versions simultaneously
<?php $func = function($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.6
Deprecated: Method ReflectionParameter::isArray() is deprecated in /in/XUXRG on line 9 Giving individuals. Result: 5 10
Output for 5.4.2 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Giving individuals. Result: 5 10

preferences:
196.28 ms | 403 KiB | 225 Q