3v4l.org

run code in 300+ PHP versions simultaneously
<?php <?php function call_user_func_fixed() { $args = func_get_args(); $callable = array_shift($args); call_user_func_array_fixed($callable, $args); } function call_user_func_array_fixed($callable, $args) { $isStaticMethod = false; if (is_object($callable) && $callable instanceof \Closure) { $func = $callable; } else if (is_string($callable)) { if (preg_match('/^([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)::([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)$/', $callable, $matches)) { $func = array($matches[1], $matches[2]); $isStaticMethod = true; } else { $func = $callable; } } else if (is_array($callable) && isset($callable[0], $callable[1]) && count($callable) === 2) { if (is_object($callable[0])) { $func = $callable; } else if (is_string($callable[0])) { $func = $callable; $isStaticMethod = true; } } if (!isset($callable) || !is_callable($callable)) { trigger_error('call_user_func() expects parameter 1 to be a valid callback', E_USER_WARNING); return null; } if (!$isStaticMethod) { return call_user_func_array($func, $args); } try { $class = new ReflectionClass($func[0]); $method = $class->getMethod(ReflectionMethod::IS_STATIC); } catch (ReflectionException $e) { trigger_error('call_user_func() expects parameter 1 to be a valid callback', E_USER_WARNING); return null; } return $method->invokeArgs($args); } class Car { public function run() { return call_user_func_fixed('Toyota::getName'); // should call toyota } private static function getName() { return 'Car'; } } class Toyota extends Car { public static function getName() { return 'Toyota'; } } $car = new Car(); echo $car->run(); //Car instead of Toyota $toyota = new Toyota(); echo $toyota->run(); //Car instead of Toyota

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.130.0190.04112.03
5.4.120.0160.04111.99
5.4.110.0140.04311.99
5.4.100.0210.06711.99
5.4.90.0200.05311.98
5.4.80.0180.04111.99
5.4.70.0140.04311.98
5.4.60.0160.03911.98
5.4.50.0150.04311.98
5.4.40.0140.04411.97
5.4.30.0140.04511.96
5.4.20.0230.06511.96
5.4.10.0210.04211.97
5.4.00.0150.04311.46
5.3.230.0190.04712.71
5.3.220.0240.06712.68
5.3.210.0230.05412.68
5.3.200.0170.04612.68
5.3.190.0140.04812.68
5.3.180.0230.06712.67
5.3.170.0160.04412.67
5.3.160.0190.04612.68
5.3.150.0190.04012.67
5.3.140.0240.06712.66
5.3.130.0180.06012.66
5.3.120.0130.05112.66
5.3.110.0160.04512.66
5.3.100.0160.04612.12
5.3.90.0150.04612.08
5.3.80.0180.04612.07
5.3.70.0250.06712.07
5.3.60.0140.04412.06
5.3.50.0160.04512.00
5.3.40.0230.05412.00
5.3.30.0180.04211.94
5.3.20.0140.04311.71
5.3.10.0110.04611.67
5.3.00.0150.04211.66

preferences:
135.76 ms | 1398 KiB | 7 Q