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; } var_dump($invokeContext, $args); // 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('self', '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.60.0090.00916.88
8.3.50.0090.01117.38
8.3.40.0070.00718.84
8.3.30.0110.00418.96
8.3.20.0060.00318.77
8.3.10.0080.00318.71
8.3.00.0000.01519.38
8.2.180.0090.00925.92
8.2.170.0040.01118.91
8.2.160.0100.00322.96
8.2.150.0060.00324.18
8.2.140.0030.00524.66
8.2.130.0000.00826.16
8.2.120.0060.00319.89
8.2.110.0030.00721.00
8.2.100.0120.00317.78
8.2.90.0000.00920.47
8.2.80.0040.00417.97
8.2.70.0050.00317.93
8.2.60.0040.00418.03
8.2.50.0040.00418.10
8.2.40.0060.00319.38
8.2.30.0000.00819.28
8.2.20.0070.00317.86
8.2.10.0080.00017.68
8.2.00.0040.00417.79
8.1.280.0060.01325.92
8.1.270.0050.00323.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00622.01
8.1.230.0120.00020.96
8.1.220.0080.00017.79
8.1.210.0080.00018.96
8.1.200.0040.00417.38
8.1.190.0080.00017.36
8.1.180.0030.00518.10
8.1.170.0090.00018.84
8.1.160.0040.00419.08
8.1.150.0040.00418.61
8.1.140.0080.00017.41
8.1.130.0000.00717.44
8.1.120.0000.00717.50
8.1.110.0090.00017.41
8.1.100.0020.00517.50
8.1.90.0000.00817.41
8.1.80.0000.00717.41
8.1.70.0000.00717.50
8.1.60.0080.00017.63
8.1.50.0080.00017.60
8.1.40.0000.00917.59
8.1.30.0090.00017.71
8.1.20.0080.00017.58
8.1.10.0040.00417.51
8.1.00.0000.00817.54
8.0.300.0040.00419.98
8.0.290.0060.00616.88
8.0.280.0080.00018.41
8.0.270.0060.00317.32
8.0.260.0030.00516.85
8.0.250.0040.00417.07
8.0.240.0000.01017.07
8.0.230.0080.00017.06
8.0.220.0090.00016.92
8.0.210.0020.00516.85
8.0.200.0060.00017.10
8.0.190.0040.00417.07
8.0.180.0000.01017.11
8.0.170.0030.00617.07
8.0.160.0040.00417.10
8.0.150.0040.00417.00
8.0.140.0000.00916.93
8.0.130.0030.00313.42
8.0.120.0070.00615.20
8.0.110.0080.00315.16
8.0.100.0110.00215.21
8.0.90.0100.00215.21
8.0.80.0090.00615.24
8.0.70.0110.00215.18
8.0.60.0050.00715.21
8.0.50.0100.00115.18
8.0.30.0060.01215.32
8.0.20.0120.00716.03
8.0.10.0080.00415.37
8.0.00.0090.00915.92
7.4.330.0030.00313.03
7.4.320.0030.00316.57
7.4.300.0000.00816.48
7.4.290.0030.00316.63
7.4.280.0070.00016.49
7.4.270.0070.00016.66
7.4.260.0030.00313.34
7.4.250.0100.00415.03
7.4.240.0100.00514.94
7.4.230.0130.00215.01
7.4.220.0090.00814.92
7.4.210.0140.00314.96
7.4.200.0100.00214.97
7.4.190.0060.00715.11
7.4.180.0140.00413.38
7.4.160.0110.00614.93
7.4.150.0110.00714.91
7.4.140.0070.01415.60
7.4.130.0150.00614.89
7.4.120.0130.01014.88
7.4.110.0090.01115.00
7.4.100.0100.00814.91
7.4.90.0130.00814.94
7.4.80.0100.00816.34
7.4.70.0100.00714.96
7.4.60.0130.00315.03
7.4.50.0020.00614.94
7.4.40.0050.00714.93
7.4.30.0060.00714.85
7.4.20.0050.00913.30
7.4.10.0070.00413.23
7.4.00.0080.00614.04
7.3.330.0080.00113.41
7.3.320.0040.00413.41
7.3.310.0080.00114.87
7.3.300.0030.00714.94
7.3.290.0080.00615.70
7.3.280.0070.01214.87
7.3.270.0090.00714.81
7.3.260.0090.00714.90
7.3.250.0110.00013.43
7.3.240.0100.00515.08
7.3.230.0130.00214.97
7.3.220.0140.00013.23
7.3.210.0120.00714.95
7.3.200.0070.01214.79
7.3.190.0080.00614.81
7.3.180.0130.00315.00
7.3.170.0140.00214.85
7.3.160.0100.00714.92
7.3.150.0130.00313.00
7.3.140.0110.00213.41
7.3.130.0130.00013.34
7.3.120.0080.00814.30
7.3.110.0170.00013.34
7.3.100.0070.00413.11
7.3.90.0070.00313.63
7.3.80.0080.00613.43
7.3.70.0160.00013.48
7.3.60.0110.00413.48
7.3.50.0110.00313.51
7.3.40.0040.00813.39
7.3.30.0070.00213.39
7.3.20.0080.00415.29
7.3.10.0110.00715.68
7.3.00.0130.00515.83
7.2.340.0080.00813.46
7.2.330.0050.01015.01
7.2.320.0130.00315.11
7.2.310.0090.00615.16
7.2.300.0090.00615.15
7.2.290.0110.00515.04
7.2.280.0080.00413.36
7.2.270.0120.00013.45
7.2.260.0040.00813.32
7.2.250.0110.00213.53
7.2.240.0060.00913.40
7.2.230.0130.00013.47
7.2.220.0060.00613.47
7.2.210.0080.00413.45
7.2.200.0040.00913.61
7.2.190.0130.00013.59
7.2.180.0070.00713.64
7.2.170.0110.00313.50
7.2.160.0070.00713.65
7.2.150.0150.00015.35
7.2.140.0070.00515.21
7.2.130.0130.00215.93
7.2.120.0100.00715.94
7.2.110.0110.00615.90
7.2.100.0080.00815.80
7.2.90.0130.00715.82
7.2.80.0120.00315.79
7.2.70.0160.00415.71
7.2.60.0100.00915.81
7.2.50.0150.00615.79
7.2.40.0130.00516.04
7.2.30.0120.00515.84
7.2.20.0140.00416.10
7.2.10.0140.00516.09
7.2.00.0080.00817.04
7.1.330.0080.00414.27
7.1.320.0090.00314.38
7.1.310.0050.00514.17
7.1.300.0070.00414.21
7.1.290.0090.00314.20
7.1.280.0040.00814.17
7.1.270.0040.00814.37
7.1.260.0110.00014.37
7.1.250.0080.00714.77
7.1.240.0040.00814.18
7.1.230.0060.00614.40
7.1.220.0130.00014.32
7.1.210.0120.00014.41
7.1.200.0090.00314.39
7.1.190.0100.00314.41
7.1.180.0080.00514.16
7.1.170.0140.00014.14
7.1.160.0030.00914.29
7.1.150.0070.00514.15
7.1.140.0080.00514.20
7.1.130.0060.00614.14
7.1.120.0040.00814.33
7.1.110.0130.00014.39
7.1.100.0070.00416.22
7.1.90.0130.00014.35
7.1.80.0060.00614.34
7.1.70.0060.00415.48
7.1.60.0060.00615.73
7.1.50.0110.00215.68
7.1.40.0110.00014.41
7.1.30.0110.00314.33
7.1.20.0130.00014.16
7.1.10.0090.00214.37
7.1.00.0050.02018.36
7.0.330.0130.00014.20
7.0.320.0080.00414.30
7.0.310.0110.00014.05
7.0.300.0080.00414.10
7.0.290.0060.00614.10
7.0.280.0120.00014.23
7.0.270.0080.00414.14
7.0.260.0050.00614.24
7.0.250.0120.00014.27
7.0.240.0070.00414.21
7.0.230.0110.00014.27
7.0.220.0110.00014.21
7.0.210.0050.00514.14
7.0.200.0020.01115.52
7.0.190.0130.00014.39
7.0.180.0060.00614.27
7.0.170.0110.00014.25
7.0.160.0060.00614.08
7.0.150.0090.00314.28
7.0.140.0030.04118.04
7.0.130.0060.00614.39
7.0.120.0030.03618.25
7.0.110.0090.02317.08
7.0.100.0120.02517.12
7.0.90.0100.03817.11
7.0.80.0080.02717.10
7.0.70.0100.02117.11
7.0.60.0050.02417.00
7.0.50.0110.01816.93
7.0.40.0040.02616.92
7.0.30.0040.02017.03
7.0.20.0110.01316.99
7.0.10.0090.01516.96
7.0.00.0050.02316.98
5.6.400.0060.00612.85
5.6.390.0060.00612.71
5.6.380.0060.00613.01
5.6.370.0080.00412.63
5.6.360.0120.00012.70
5.6.350.0090.00212.84
5.6.340.0100.00312.67
5.6.330.0090.00212.89
5.6.320.0060.00612.92
5.6.310.0120.00012.83
5.6.300.0110.00012.57
5.6.290.0060.00613.00
5.6.280.0110.03416.99
5.6.270.0120.00012.86
5.6.260.0080.02016.73
5.6.250.0070.02216.81
5.6.240.0080.04316.83
5.6.230.0030.02516.67
5.6.220.0020.02516.91
5.6.210.0040.02316.88
5.6.200.0020.02616.93
5.6.190.0070.02016.84
5.6.180.0080.02016.93
5.6.170.0090.01816.88
5.6.160.0030.02016.96
5.6.150.0040.02016.80
5.6.140.0070.01816.77
5.6.130.0080.01616.86
5.6.120.0120.01516.72
5.6.110.0090.02016.65
5.6.100.0060.01816.78
5.6.90.0090.01716.76
5.6.80.0030.02116.41
5.6.70.0060.01816.49
5.6.60.0050.03116.38
5.6.50.0030.02116.42
5.6.40.0060.01816.43
5.6.30.0050.04116.49
5.6.20.0040.04716.38
5.6.10.0110.03216.35
5.6.00.0110.01516.52
5.5.380.0050.03215.15
5.5.370.0070.02315.19
5.5.360.0050.02215.22
5.5.350.0100.01915.33
5.5.340.0040.02615.35
5.5.330.0090.01615.55
5.5.320.0020.02615.61
5.5.310.0080.02015.46
5.5.300.0060.02215.37
5.5.290.0080.02115.58
5.5.280.0040.02115.39
5.5.270.0080.01715.46
5.5.260.0060.02215.41
5.5.250.0080.01715.51
5.5.240.0060.01815.14
5.5.230.0040.02215.22
5.5.220.0080.01815.08
5.5.210.0120.02715.21
5.5.200.0070.03915.20
5.5.190.0070.02015.12
5.5.180.0120.01514.91
5.5.170.0110.00312.54
5.5.160.0100.01515.22
5.5.150.0070.04215.00
5.5.140.0110.03314.99
5.5.130.0020.04215.05
5.5.120.0100.03815.03
5.5.110.0070.02015.15
5.5.100.0090.02515.17
5.5.90.0080.03815.22
5.5.80.0090.03715.00
5.5.70.0080.04015.17
5.5.60.0070.03314.99
5.5.50.0050.03815.00
5.5.40.0050.02115.16
5.5.30.0080.03015.03
5.5.20.0130.03315.16
5.5.10.0120.02015.04
5.5.00.0060.02015.01
5.4.450.0080.01616.07
5.4.440.0060.02715.97
5.4.430.0080.01816.10
5.4.420.0050.02016.05
5.4.410.0020.02116.13
5.4.400.0080.01615.83
5.4.390.0100.01615.96
5.4.380.0090.02515.89
5.4.370.0050.02015.80
5.4.360.0060.01815.96
5.4.350.0070.01915.81
5.4.340.0050.02115.81
5.4.330.0090.00212.64
5.4.320.0080.01815.93
5.4.310.0100.02316.02
5.4.300.0090.03516.03
5.4.290.0070.03915.89
5.4.280.0070.02316.05
5.4.270.0090.03815.80
5.4.260.0030.04115.91
5.4.250.0070.01915.96
5.4.240.0040.03015.93
5.4.230.0060.02715.84
5.4.220.0090.01815.95
5.4.210.0070.03015.82
5.4.200.0040.02315.85
5.4.190.0110.03315.90
5.4.180.0080.03315.79
5.4.170.0050.04016.05
5.4.160.0070.03716.05
5.4.150.0080.03016.02
5.4.140.0060.03714.62
5.4.130.0080.03914.76
5.4.120.0040.03214.64
5.4.110.0050.04314.77
5.4.100.0040.02814.73
5.4.90.0050.02014.80
5.4.80.0120.03214.77
5.4.70.0070.02214.77
5.4.60.0070.03414.79
5.4.50.0080.03714.69
5.4.40.0060.02714.56
5.4.30.0070.02214.61
5.4.20.0070.03814.69
5.4.10.0120.03214.65
5.4.00.0080.02614.33
5.3.290.0110.03813.92
5.3.280.0050.01913.90
5.3.270.0040.02113.91
5.3.260.0080.01813.84
5.3.250.0030.02013.94
5.3.240.0080.03813.78
5.3.230.0090.01714.01
5.3.220.0020.03713.81
5.3.210.0070.04113.86
5.3.200.0040.04213.79
5.3.190.0030.04214.03
5.3.180.0100.03213.97
5.3.170.0030.04213.79
5.3.160.0040.02413.91
5.3.150.0070.03913.87
5.3.140.0040.03013.86
5.3.130.0060.02513.84
5.3.120.0070.04213.88
5.3.110.0030.04213.82
5.3.100.0090.03513.68
5.3.90.0060.02313.66
5.3.80.0060.03413.60
5.3.70.0100.02513.56
5.3.60.0080.03813.61
5.3.50.0100.03313.59
5.3.40.0090.03513.44
5.3.30.0050.03713.59
5.3.20.0020.04113.45
5.3.10.0030.02313.37
5.3.00.0070.03513.19
5.2.170.0030.04011.91
5.2.160.0030.05311.91
5.2.150.0070.04011.91
5.2.140.0070.06311.91
5.2.130.0070.06011.91
5.2.120.0070.03711.91
5.2.110.0030.06311.91
5.2.100.0070.05711.91
5.2.90.0070.05311.91
5.2.80.0030.06311.91
5.2.70.0030.06011.91
5.2.60.0030.06311.91
5.2.50.0100.05311.91
5.2.40.0070.04311.91
5.2.30.0100.05311.91
5.2.20.0030.06011.91
5.2.10.0030.05311.91
5.2.00.0000.05011.91
5.1.60.0070.05011.91
5.1.50.0000.02311.91
5.1.40.0030.04011.91
5.1.30.0130.04311.91
5.1.20.0030.05311.91
5.1.10.0070.04311.91
5.1.00.0000.06011.91
5.0.50.0000.03711.91
5.0.40.0030.04311.91
5.0.30.0030.03711.91
5.0.20.0030.02711.91
5.0.10.0000.04311.91
5.0.00.0070.06011.91
4.4.90.0030.03311.91
4.4.80.0030.03311.91
4.4.70.0000.03711.91
4.4.60.0030.03711.91
4.4.50.0030.03311.91
4.4.40.0030.05311.91
4.4.30.0030.03311.91
4.4.20.0030.03311.91
4.4.10.0070.03011.91
4.4.00.0030.05711.91
4.3.110.0000.03311.91
4.3.100.0000.03711.91
4.3.90.0030.03011.91
4.3.80.0070.04011.91
4.3.70.0000.03311.91
4.3.60.0030.02311.91
4.3.50.0100.02711.91
4.3.40.0030.05311.91
4.3.30.0000.02711.91
4.3.20.0000.03711.91
4.3.10.0030.03311.91
4.3.00.0000.02311.91

preferences:
51.57 ms | 401 KiB | 5 Q