3v4l.org

run code in 300+ PHP versions simultaneously
<?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; $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.70.0150.00018.55
8.3.60.0080.01216.36
8.3.50.0210.00916.43
8.3.40.0120.00318.81
8.3.30.0110.00419.02
8.3.20.0080.00018.81
8.3.10.0080.00020.66
8.3.00.0040.00419.26
8.2.180.0090.00618.29
8.2.170.0070.00722.96
8.2.160.0120.00321.20
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0150.00019.48
8.2.110.0060.00321.11
8.2.100.0110.00017.84
8.2.90.0040.00419.35
8.2.80.0030.00617.97
8.2.70.0080.00017.63
8.2.60.0030.00517.93
8.2.50.0000.00818.10
8.2.40.0060.00318.34
8.2.30.0070.00418.09
8.2.20.0040.00417.78
8.2.10.0000.00817.73
8.2.00.0040.00417.69
8.1.280.0000.01525.92
8.1.270.0070.00024.66
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00622.74
8.1.230.0040.00717.70
8.1.220.0000.00817.77
8.1.210.0000.00918.77
8.1.200.0040.00417.47
8.1.190.0050.00317.48
8.1.180.0000.00718.10
8.1.170.0040.00418.91
8.1.160.0050.00318.99
8.1.150.0040.00418.63
8.1.140.0040.00417.51
8.1.130.0070.00017.84
8.1.120.0040.00417.50
8.1.110.0080.00017.52
8.1.100.0040.00417.37
8.1.90.0060.00617.43
8.1.80.0040.00417.41
8.1.70.0030.00317.46
8.1.60.0030.00517.63
8.1.50.0000.00817.57
8.1.40.0070.00017.64
8.1.30.0050.00317.78
8.1.20.0040.00417.70
8.1.10.0000.00817.62
8.1.00.0070.00017.57
8.0.300.0070.00018.77
8.0.290.0000.00716.88
8.0.280.0030.00318.41
8.0.270.0000.00817.30
8.0.260.0070.00016.88
8.0.250.0040.00417.03
8.0.240.0040.00417.01
8.0.230.0000.00716.90
8.0.220.0030.00617.01
8.0.210.0070.00016.93
8.0.200.0000.00817.08
8.0.190.0000.00817.03
8.0.180.0070.00016.86
8.0.170.0000.00816.87
8.0.160.0000.00816.93
8.0.150.0000.00816.88
8.0.140.0080.00016.95
8.0.130.0030.00313.37
8.0.120.0030.00516.98
8.0.110.0000.00716.81
8.0.100.0040.00416.79
8.0.90.0000.00816.95
8.0.80.0100.00616.91
8.0.70.0000.00717.00
8.0.60.0000.00817.05
8.0.50.0000.00817.00
8.0.30.0120.01117.10
8.0.20.0090.00916.97
8.0.10.0030.00617.09
8.0.00.0060.01616.72
7.4.330.0020.00213.12
7.4.320.0000.00816.71
7.4.300.0040.00416.61
7.4.290.0070.00016.71
7.4.280.0080.00016.66
7.4.270.0000.00816.64
7.4.260.0000.00513.33
7.4.250.0050.00516.65
7.4.240.0040.00416.55
7.4.230.0000.00716.47
7.4.220.0060.01216.61
7.4.210.0040.01316.61
7.4.200.0000.00716.68
7.4.190.0000.00816.75
7.4.160.0060.00916.63
7.4.150.0100.00716.55
7.4.140.0110.00616.60
7.4.130.0080.01016.61
7.4.120.0140.00316.58
7.4.110.0100.00716.42
7.4.100.0190.00716.64
7.4.90.0090.01316.47
7.4.80.0130.00719.39
7.4.70.0040.01416.54
7.4.60.0050.01516.50
7.4.50.0060.00016.48
7.4.40.0070.00416.27
7.4.30.0120.00416.50
7.4.10.0150.00315.29
7.4.00.0100.00415.01
7.3.330.0060.00013.42
7.3.320.0030.00313.42
7.3.310.0000.00816.29
7.3.300.0000.00716.43
7.3.290.0140.00816.38
7.3.280.0060.01116.44
7.3.270.0120.00616.66
7.3.260.0090.00916.46
7.3.250.0150.00616.52
7.3.240.0170.00616.36
7.3.230.0070.01116.61
7.3.210.0090.00916.40
7.3.200.0090.00916.54
7.3.190.0170.00016.42
7.3.180.0060.01016.44
7.3.170.0100.01016.55
7.3.160.0100.01116.42
7.3.130.0130.00714.83
7.3.120.0090.00815.08
7.3.110.0040.01114.93
7.3.100.0060.00914.99
7.3.90.0090.00614.98
7.3.80.0040.00714.94
7.3.70.0100.00615.11
7.3.60.0060.00914.80
7.3.50.0060.01014.92
7.3.40.0030.01014.73
7.3.30.0060.01014.99
7.3.20.0160.00316.80
7.3.10.0000.01816.73
7.3.00.0110.00316.58
7.2.330.0070.01116.84
7.2.320.0120.00916.77
7.2.310.0130.00716.80
7.2.300.0060.01316.91
7.2.290.0130.00916.86
7.2.260.0090.00915.24
7.2.250.0100.00715.02
7.2.240.0000.01415.12
7.2.230.0100.00715.17
7.2.220.0030.00615.06
7.2.210.0000.01515.13
7.2.200.0000.01615.10
7.2.190.0080.00415.26
7.2.180.0040.01114.93
7.2.170.0000.01415.34
7.2.160.0060.00915.08
7.2.150.0070.01016.76
7.2.140.0070.01316.70
7.2.130.0040.01516.72
7.2.120.0040.01816.95
7.2.110.0100.00716.90
7.2.100.0080.00417.06
7.2.90.0090.00916.79
7.2.80.0100.01017.05
7.2.70.0080.00416.97
7.2.60.0070.00717.02
7.2.50.0060.00917.10
7.2.40.0030.01016.99
7.2.30.0100.00316.98
7.2.20.0090.00617.00
7.2.10.0060.00616.83
7.2.00.0050.01018.26
7.1.330.0060.00315.70
7.1.320.0130.00315.88
7.1.310.0080.00815.95
7.1.300.0000.01015.96
7.1.290.0070.00715.54
7.1.280.0030.01015.82
7.1.270.0000.01315.93
7.1.260.0030.00915.80
7.1.250.0000.01115.61
7.1.240.0060.00916.05
7.1.230.0160.00315.54
7.1.220.0000.01115.96
7.1.210.0070.01115.85
7.1.200.0060.00915.73
7.1.190.0070.00415.83
7.1.180.0100.00315.79
7.1.170.0070.00715.55
7.1.160.0030.00715.66
7.1.150.0000.00915.93
7.1.140.0060.00615.86
7.1.130.0060.00615.95
7.1.120.0060.00615.90
7.1.110.0060.00615.63
7.1.100.0010.01117.05
7.1.90.0100.00315.93
7.1.80.0080.00415.92
7.1.70.0030.01016.37
7.1.60.0060.01017.65
7.1.50.0040.00916.26
7.1.40.0000.01515.71
7.1.30.0030.01215.78
7.1.20.0070.00715.63
7.1.10.0070.00415.52
7.1.00.0040.03319.17
7.0.330.0100.00315.38
7.0.320.0100.00315.45
7.0.310.0060.00915.49
7.0.300.0040.00715.43
7.0.290.0070.00715.34
7.0.280.0090.00915.10
7.0.270.0030.00915.47
7.0.260.0030.01315.55
7.0.250.0090.00315.50
7.0.240.0060.01215.67
7.0.230.0060.01215.47
7.0.220.0060.00915.21
7.0.210.0090.00615.51
7.0.200.0170.00914.83
7.0.190.0030.01415.52
7.0.180.0090.00915.52
7.0.170.0160.00015.46
7.0.160.0000.00815.27
7.0.150.0070.00715.30
7.0.140.0000.04318.75
7.0.130.0070.01015.57
7.0.120.0030.03518.63
7.0.110.0070.00415.11
7.0.100.0000.01515.30
7.0.90.0000.01215.32
7.0.80.0060.00915.26
7.0.70.0000.01415.62
7.0.60.0060.05017.60
7.0.50.0030.04816.67
7.0.40.0080.03216.83
7.0.30.0130.02516.86
7.0.20.0150.04316.70
7.0.10.0150.02816.82
7.0.00.0140.02316.86
5.6.400.0040.01114.55
5.6.390.0070.01014.40
5.6.380.0070.00714.61
5.6.370.0000.01414.70
5.6.360.0070.00714.71
5.6.350.0060.01014.40
5.6.340.0030.01014.44
5.6.330.0040.01414.34
5.6.320.0030.01114.26
5.6.310.0100.00314.82
5.6.300.0000.01314.63
5.6.290.0100.00314.45
5.6.280.0020.04317.87
5.6.270.0040.00714.29
5.6.260.0110.00314.50
5.6.250.0070.00314.57
5.6.240.0030.01014.43
5.6.230.0030.00914.50
5.6.220.0060.00614.27
5.6.210.0070.04417.36
5.6.200.0080.02916.32
5.6.190.0110.04517.59
5.6.180.0220.03517.36
5.6.170.0180.03217.56
5.6.160.0070.03717.40
5.6.150.0070.04016.27
5.6.140.0080.02316.47
5.6.130.0120.03216.25
5.6.120.0050.04617.88
5.6.110.0070.03517.70
5.6.100.0070.04417.69
5.6.90.0060.04617.94
5.6.80.0060.04817.44
5.6.70.2180.02917.42
5.6.60.0070.00714.30
5.6.50.0150.00014.52
5.6.40.0070.01014.24
5.6.30.0060.01014.35
5.6.20.0060.00314.39
5.6.10.0030.01314.38
5.6.00.0050.00514.54
5.5.380.0070.00714.37
5.5.370.0100.00714.43
5.5.360.0130.00314.23
5.5.350.0150.04617.34
5.5.340.0120.03316.42
5.5.330.0070.02617.35
5.5.320.0150.03417.28
5.5.310.0160.03717.45
5.5.300.0050.04516.16
5.5.290.0070.03016.02
5.5.280.0150.03017.61
5.5.270.0110.04317.66
5.5.260.0070.02017.64
5.5.250.0070.04517.49
5.5.240.0100.03417.33
5.5.230.0070.00714.31
5.5.220.0000.01214.10
5.5.210.0120.00314.41
5.5.200.0110.00714.04
5.5.190.0100.00313.86
5.5.180.0080.00614.36
5.5.170.0030.01014.47
5.5.160.0070.01014.55
5.5.150.0070.00714.45
5.5.140.0100.00614.63
5.5.130.0060.00614.15
5.5.120.0070.00714.37
5.5.110.0110.00414.50
5.5.100.0030.01314.55
5.5.90.0090.00614.55
5.5.80.0090.00613.99
5.5.70.0060.00614.38
5.5.60.0060.01014.54
5.5.50.0040.00714.09
5.5.40.0080.00414.61
5.5.30.0100.00014.17
5.5.20.0060.00314.26
5.5.10.0070.00714.55
5.5.00.0070.00414.37
5.4.450.0030.04116.00
5.4.440.0030.04316.16
5.4.430.0060.04316.15
5.4.420.0080.04116.15
5.4.410.0040.04115.91
5.4.400.0060.04116.00
5.4.390.0070.04215.84
5.4.380.0090.04115.97
5.4.370.0080.04315.81
5.4.360.0090.04415.95
5.4.350.0050.02915.83
5.4.340.0040.02415.91
5.4.330.0000.01112.75
5.4.320.0070.02815.95
5.4.310.0020.04516.00
5.4.300.0070.03715.95
5.4.290.0080.03715.81
5.4.280.0050.03015.79
5.4.270.0080.02315.83
5.4.260.0030.03515.95
5.4.250.0050.04415.94
5.4.240.0120.03215.91
5.4.230.0070.02515.94
5.4.220.0030.03215.95
5.4.210.0050.02815.99
5.4.200.0110.03715.93
5.4.190.0080.02515.87
5.4.180.0070.02515.91
5.4.170.0080.04315.99
5.4.160.0070.02315.94
5.4.150.0050.03915.94
5.4.140.0050.03914.64
5.4.130.0030.03814.59
5.4.120.0000.03014.65
5.4.110.0050.03714.59
5.4.100.0060.03014.60
5.4.90.0040.04214.64
5.4.80.0040.02214.60
5.4.70.0100.02814.61
5.4.60.0020.04314.71
5.4.50.0030.04314.52
5.4.40.0120.03514.58
5.4.30.0050.02214.60
5.4.20.0100.03814.60
5.4.10.0120.03514.58
5.4.00.0050.04014.27
5.3.290.0090.02813.75
5.3.280.0050.04213.77
5.3.270.0030.04213.72
5.3.260.0070.03413.65
5.3.250.0080.03713.69
5.3.240.0080.04013.70
5.3.230.0100.03513.69
5.3.220.0020.03613.69
5.3.210.0060.04313.70
5.3.200.0050.03813.69
5.3.190.0050.02513.63
5.3.180.0060.02813.70
5.3.170.0070.03413.71
5.3.160.0070.03713.69
5.3.150.0080.03813.62
5.3.140.0050.04213.67
5.3.130.0070.02813.67
5.3.120.0070.03513.69
5.3.110.0030.04113.67
5.3.100.0030.02513.43
5.3.90.0000.02413.43
5.3.80.0050.01913.36
5.3.70.0060.03113.36
5.3.60.0020.02313.37
5.3.50.0070.03813.37
5.3.40.0060.03813.44
5.3.30.0030.02713.32
5.3.20.0080.02113.31
5.3.10.0050.03713.21
5.3.00.0050.03713.18
5.2.170.0030.05711.19
5.2.160.0100.04011.24
5.2.150.0030.03011.15
5.2.140.0030.05311.13
5.2.130.0000.06711.29
5.2.120.0100.03011.09
5.2.110.0070.06011.18
5.2.100.0070.05311.20
5.2.90.0070.05011.14
5.2.80.0030.05311.23
5.2.70.0070.05711.19
5.2.60.0070.04311.05
5.2.50.0070.02711.05
5.2.40.0030.03711.08
5.2.30.0000.03311.06
5.2.20.0100.05711.07
5.2.10.0030.04710.82
5.2.00.0100.04310.81
5.1.60.0100.04710.03
5.1.50.0130.04710.05
5.1.40.0000.03710.09
5.1.30.0000.03710.33
5.1.20.0030.03310.38
5.1.10.0030.03710.02
5.1.00.0100.04010.18
5.0.50.0070.0438.61
5.0.40.0070.0408.54
5.0.30.0000.0678.47
5.0.20.0070.0408.26
5.0.10.0000.0438.23
5.0.00.0030.0608.32
4.4.90.0000.0307.99
4.4.80.0000.0177.99
4.4.70.0030.0377.99
4.4.60.0000.0277.99
4.4.50.0130.0237.99
4.4.40.0000.0577.99
4.4.30.0000.0237.99
4.4.20.0030.0307.99
4.4.10.0000.0377.99
4.4.00.0100.0307.99
4.3.110.0070.0337.99
4.3.100.0000.0307.99
4.3.90.0030.0307.99
4.3.80.0100.0437.99
4.3.70.0000.0407.99
4.3.60.0030.0277.99
4.3.50.0000.0277.99
4.3.40.0030.0507.99
4.3.30.0000.0307.99
4.3.20.0000.0207.99
4.3.10.0000.0377.99
4.3.00.0000.0407.99

preferences:
59.76 ms | 401 KiB | 5 Q