3v4l.org

run code in 300+ PHP versions simultaneously
<?php function call_user_func_fixed() { $args = func_get_args(); $callable = array_shift($args); return call_user_func_array_fixed($callable, $args); } function call_user_func_array_fixed($callable, $args) { $isStaticMethod = false; $expr = '/^([a-z_\x7f-\xff][\w\x7f-\xff]*)::([a-z_\x7f-\xff][\w\x7f-\xff]*)$/i'; // Extract the callable normalized to an array if it looks like a method call if (is_string($callable) && preg_match($expr, $callable, $matches)) { $func = array($matches[1], $matches[2]); } else if (is_array($callable) && count($callable) === 2 && isset($callable[0], $callable[1]) && (is_string($callable[0]) || is_object($callable[0])) && is_string($callable[1])) { $func = $callable; } // If we're not interested in it use the regular mechanism if (!isset($func)) { return call_user_func_array($func, $args); } $backtrace = debug_backtrace(); // passing args here is fraught with complications for backwards compat :-( if ($backtrace[1]['function'] === 'call_user_func_fixed') { $called = 'call_user_func_fixed'; $contextKey = 2; } else { $called = 'call_user_func_array_fixed'; $contextKey = 1; } try { // Get a reference to the target static method if possible switch (true) { case $func[0] === 'self': if (!isset($backtrace[$contextKey]['object'])) { throw new Exception('Use of self:: in an invalid context'); } $method = new ReflectionMethod($backtrace[$contextKey]['class'], $func[1]); $invokeContext = $backtrace[$contextKey]['object']; break; case $func[0] === 'static': if (!isset($backtrace[$contextKey]['object'])) { throw new Exception('Use of static:: in an invalid context'); } $method = new ReflectionMethod($backtrace[$contextKey]['object'], $func[1]); $invokeContext = $backtrace[$contextKey]['object']; break; case $func[0] === 'parent': if (!isset($backtrace[$contextKey]['object'])) { throw new Exception('Use of static:: in an invalid context'); } $method = new ReflectionMethod($backtrace[$contextKey]['object'], $func[1]); if ($method->getDeclaringClass()->getName() === $backtrace[$contextKey]['class']) { $method = $method->getPrototype(); } $invokeContext = $backtrace[$contextKey]['object']; break; case is_object($func[0]): $method = new ReflectionMethod($func[0], $func[1]); $invokeContext = $func[0]; break; default: $method = new ReflectionMethod($func[0], $func[1]); $invokeContext = !empty($backtrace[$contextKey]['object']) ? $backtrace[$contextKey]['object'] : null; break; } // Invoke the method with the passed arguments and return the result return $method->invokeArgs($invokeContext, $args); } catch (Exception $e) { trigger_error($called . '() expects parameter 1 to be a valid callback: ' . $e->getMessage(), E_USER_ERROR); return null; } } class Car { public function run() { return call_user_func_fixed(array('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)
8.3.40.0040.01818.79
8.3.30.0070.00720.40
8.3.20.0050.00220.25
8.3.10.0040.00422.07
8.3.00.0040.00422.46
8.2.170.0110.00422.96
8.2.160.0030.01322.25
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0000.00726.16
8.2.120.0040.00420.80
8.2.110.0030.00619.29
8.2.100.0090.00317.84
8.2.90.0000.00719.36
8.2.80.0040.00419.38
8.2.70.0030.00617.63
8.2.60.0000.00817.93
8.2.50.0050.00318.07
8.2.40.0000.00918.34
8.2.30.0070.00019.40
8.2.20.0040.00717.77
8.2.10.0030.00617.74
8.2.00.0050.00317.81
8.1.270.0090.00023.99
8.1.260.0050.00326.35
8.1.250.0050.00328.09
8.1.240.0000.00824.01
8.1.230.0060.00620.98
8.1.220.0030.00618.77
8.1.210.0030.00919.01
8.1.200.0000.01117.38
8.1.190.0050.00317.75
8.1.180.0080.00018.10
8.1.170.0000.00818.73
8.1.160.0040.00418.99
8.1.150.0040.00418.61
8.1.140.0040.00417.54
8.1.130.0070.00017.79
8.1.120.0000.00717.43
8.1.110.0070.00017.42
8.1.100.0030.00517.38
8.1.90.0000.00717.39
8.1.80.0000.00817.43
8.1.70.0050.00217.50
8.1.60.0030.00617.67
8.1.50.0040.00417.61
8.1.40.0090.00017.57
8.1.30.0040.00417.63
8.1.20.0080.00017.76
8.1.10.0000.00817.63
8.1.00.0050.00317.61
8.0.300.0030.00620.08
8.0.290.0040.00417.28
8.0.280.0050.00318.55
8.0.270.0000.00717.31
8.0.260.0000.00716.89
8.0.250.0030.00316.98
8.0.240.0000.00917.00
8.0.230.0080.00016.98
8.0.220.0000.00716.91
8.0.210.0000.00816.86
8.0.200.0040.00417.03
8.0.190.0050.00316.92
8.0.180.0050.00216.88
8.0.170.0000.00716.91
8.0.160.0040.00416.98
8.0.150.0070.00016.91
8.0.140.0040.00416.93
8.0.130.0000.00513.42
8.0.120.0040.00416.95
8.0.110.0050.00316.88
8.0.100.0000.00816.84
8.0.90.0020.00516.80
8.0.80.0120.01217.00
8.0.70.0050.00217.04
8.0.60.0070.00016.90
8.0.50.0000.00817.01
8.0.30.0090.01217.19
8.0.20.0090.01017.40
8.0.10.0060.00317.08
8.0.00.0130.00716.90
7.4.330.0040.00015.11
7.4.320.0000.00616.55
7.4.300.0000.00616.59
7.4.290.0040.00416.54
7.4.280.0030.00316.66
7.4.270.0070.00016.68
7.4.260.0040.00413.25
7.4.250.0070.00016.64
7.4.240.0040.00416.56
7.4.230.0000.00716.45
7.4.220.0100.01016.70
7.4.210.0090.00616.64
7.4.200.0040.00416.64
7.4.190.0040.00416.63
7.4.160.0070.01016.60
7.4.150.0110.00817.40
7.4.140.0100.00717.86
7.4.130.0120.00716.54
7.4.120.0140.00516.62
7.4.110.0090.01216.45
7.4.100.0030.01316.74
7.4.90.0060.01216.47
7.4.80.0040.01919.39
7.4.70.0160.00016.49
7.4.60.0100.00716.54
7.4.50.0040.00416.51
7.4.40.0090.00622.77
7.4.30.0080.00816.62
7.4.00.0060.00914.70
7.3.330.0030.00313.39
7.3.320.0030.00313.22
7.3.310.0040.00316.25
7.3.300.0030.00316.41
7.3.290.0110.00316.40
7.3.280.0040.01116.43
7.3.270.0090.00917.40
7.3.260.0150.00916.46
7.3.250.0080.01016.69
7.3.240.0100.00716.44
7.3.230.0090.00616.75
7.3.210.0060.01016.47
7.3.200.0100.00719.39
7.3.190.0110.00716.76
7.3.180.0090.00916.36
7.3.170.0060.01016.64
7.3.160.0030.01316.54
7.3.120.0060.00614.82
7.2.330.0160.00316.88
7.2.320.0130.01016.78
7.2.310.0100.01016.51
7.2.300.0000.01816.88
7.2.290.0150.00916.66
7.2.00.0030.01019.17
7.1.200.0030.01115.79
7.1.100.0100.00718.20
7.1.70.0000.00817.08
7.1.60.0070.01819.21
7.1.50.0240.01216.57
7.1.00.0000.06022.39
7.0.200.0060.00616.61
7.0.140.0030.07322.07
7.0.60.0100.06020.06
7.0.50.0000.07717.94
7.0.40.0070.04020.11
7.0.30.0130.04720.16
7.0.20.0230.04020.07
7.0.10.0000.08320.16
7.0.00.0000.04720.29
5.6.280.0030.07321.17
5.6.210.0070.06320.72
5.6.200.0070.08318.19
5.6.190.0070.07720.77
5.6.180.0430.05720.41
5.6.170.0230.05020.47
5.6.160.0130.07320.47
5.6.150.0030.08318.17
5.6.140.0130.04718.28
5.6.130.0100.08018.21
5.6.120.0100.08021.12
5.6.110.0300.06721.02
5.6.100.0030.08321.04
5.6.90.0070.07721.11
5.6.80.0070.05720.38
5.5.350.0230.04020.36
5.5.340.0070.05017.93
5.5.330.0030.09020.30
5.5.320.1470.05320.42
5.5.310.0270.07720.18
5.5.300.0000.05317.94
5.5.290.0070.08018.08
5.5.280.0100.08320.79
5.5.270.0130.04720.98
5.5.260.0130.08020.78
5.5.250.0030.04020.61
5.5.240.0030.06320.21
5.4.450.2370.04319.44
5.4.440.1930.03319.39
5.4.430.0000.08719.47
5.4.420.0000.05719.21
5.4.410.1070.07319.39
5.4.400.2270.03319.20
5.4.390.2370.04019.08
5.4.380.2800.04018.97
5.4.370.2470.04319.14
5.4.360.2830.04019.24
5.4.350.2530.04319.13
5.4.340.2270.03319.06
5.4.320.2230.04719.23
5.4.310.0070.06319.15
5.4.300.0070.06318.95
5.4.290.0970.07019.22
5.4.280.2470.04018.95
5.4.270.2670.04318.97
5.4.260.2470.04719.13
5.4.250.2430.04018.83
5.4.240.2370.03718.95
5.4.230.2400.02719.13
5.4.220.2370.03319.08
5.4.210.2300.04019.01
5.4.200.0300.04019.24
5.4.190.0070.06719.17
5.4.180.0300.04318.99
5.4.170.2270.05019.08
5.4.160.2370.04319.06
5.4.150.2500.03718.98
5.4.140.2300.03316.41
5.4.130.2700.04016.46
5.4.120.2770.03716.38
5.4.110.2530.04316.25
5.4.100.2800.03716.59
5.4.90.2570.04016.30
5.4.80.2700.03716.59
5.4.70.2400.03316.44
5.4.60.2470.03716.30
5.4.50.2400.04016.27
5.4.40.2470.03716.54
5.4.30.2200.03716.56
5.4.20.2100.03716.54
5.4.10.2300.03716.48
5.4.00.2400.03715.92
5.3.290.0500.04714.77
5.3.280.0000.04014.64
5.3.270.0300.03314.66
5.3.260.2330.03714.62
5.3.250.2270.04014.89
5.3.240.2330.03714.65
5.3.230.2400.03314.54
5.3.220.2400.04314.50
5.3.210.2400.03314.53
5.3.200.2330.03714.68
5.3.190.2370.03714.52
5.3.180.2370.03014.51
5.3.170.2200.04014.72
5.3.160.2870.04714.65
5.3.150.2670.03314.52
5.3.140.2630.03314.82
5.3.130.2270.04014.59
5.3.120.2270.04314.66
5.3.110.3000.04014.59
5.3.100.2300.03314.30
5.3.90.2670.05714.13
5.3.80.1000.03313.95
5.3.70.0030.07314.06
5.3.60.0030.03713.95
5.3.50.2100.05014.06
5.3.40.2100.03714.21
5.3.30.2500.03714.17
5.3.20.2270.03313.74
5.3.10.2600.06013.70
5.3.00.2370.03313.77
5.2.170.1970.03711.14
5.2.160.2000.02711.30
5.2.150.2130.03011.19
5.2.140.1070.03011.25
5.2.130.0000.03011.05
5.2.120.0030.03311.20
5.2.110.0170.03011.12
5.2.100.1870.03011.37
5.2.90.2030.03311.05
5.2.80.1900.03011.14
5.2.70.2100.03311.09
5.2.60.1900.03311.00
5.2.50.0030.03010.96
5.2.40.0070.03710.94
5.2.30.0000.03311.12
5.2.20.1030.02710.89
5.2.10.0030.02711.06
5.2.00.0000.03010.66
5.1.60.0070.0439.97
5.1.50.0270.0439.93
5.1.40.1500.0279.91
5.1.30.0030.03010.60
5.1.20.0070.02010.62
5.1.10.0070.02010.05
5.1.00.0930.02710.34
5.0.50.0070.0208.53
5.0.40.0030.0338.62
5.0.30.0000.0338.20
5.0.20.0000.0278.16
5.0.10.0000.0278.18
5.0.00.0030.0308.15
4.4.90.0000.0177.48
4.4.80.0000.0207.48
4.4.70.0070.0107.48
4.4.60.0030.0207.48
4.4.50.0170.0137.48
4.4.40.0030.0277.48
4.4.30.0030.0307.48
4.4.20.0000.0237.49
4.4.10.0030.0307.49
4.4.00.0000.0277.52
4.3.110.0100.0277.52
4.3.100.0200.0237.52
4.3.90.0070.0277.52
4.3.80.0000.0277.52
4.3.70.0000.0377.52
4.3.60.0030.0207.54
4.3.50.0100.0137.54
4.3.40.0100.0237.55
4.3.30.0000.0207.55
4.3.20.0000.0177.55
4.3.10.0000.0307.56
4.3.00.0000.0207.56

preferences:
38.36 ms | 400 KiB | 5 Q