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';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(!isset($func)){return call_user_func_array($func,$args);}$backtrace=debug_backtrace();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{switch(true){case $func[0]==='self':if(!isset($backtrace[$contextKey]['class'])){ throw new Exception('Use of self:: in an invalid context');}$contextClass=new ReflectionClass($backtrace[$contextKey]['class']);$contextClassName=$contextClass->getName();$method=$contextClass->getMethod($func[1]);$ownerClassName=$method->getDeclaringClass()->getName();if(!$method->isStatic()){ throw new Exception('Attempting to call instance method in a static context');}$invokeContext=null;if($method->isPrivate()){if($ownerClassName!==$contextClassName||!method_exists($method,'setAccessible')){ throw new Exception('Attempting to call private method in an invalid context');}$method->setAccessible(true);}else if($method->isProtected()){if(!method_exists($method,'setAccessible')){ throw new Exception('Attempting to call protected method in an invalid context');}while($contextClass->getName()!==$ownerClassName){$contextClass=$contextClass->getParentClass();}if($contextClass->getName()!==$ownerClassName){ throw new Exception('Attempting to call protected method in an invalid context');}$method->setAccessible(true);}break;case $func[0]==='static':if(!isset($backtrace[$contextKey]['class'])){ throw new Exception('Use of static:: in an invalid context');}$contextClass=new ReflectionClass($backtrace[$contextKey]['object']);$contextClassName=$contextClass->getName();$method=$contextClass->getMethod($func[1]);$ownerClassName=$method->getDeclaringClass()->getName();if(!$method->isStatic()){ throw new Exception('Attempting to call instance method in a static context');}$invokeContext=null;if($method->isPrivate()){if($ownerClassName!==$contextClassName||!method_exists($method,'setAccessible')){ throw new Exception('Attempting to call private method in an invalid context');}$method->setAccessible(true);}else if($method->isProtected()){if(!method_exists($method,'setAccessible')){ throw new Exception('Attempting to call protected method in an invalid context');}while($contextClass->getName()!==$ownerClassName){$contextClass=$contextClass->getParentClass();}if($contextClass->getName()!==$ownerClassName){ throw new Exception('Attempting to call protected method in an invalid context');}$method->setAccessible(true);}break;case is_object($func[0]):$contextClass=new ReflectionClass($func[0]);$contextClassName=$contextClass->getName();$method=$contextClass->getMethod($func[1]);$ownerClassName=$method->getDeclaringClass()->getName();if($method->isStatic()){$invokeContext=null;if($method->isPrivate()){if($ownerClassName!==$contextClassName||!method_exists($method,'setAccessible')){ throw new Exception('Attempting to call private method in an invalid context');}$method->setAccessible(true);}else if($method->isProtected()){if(!method_exists($method,'setAccessible')){ throw new Exception('Attempting to call protected method in an invalid context');}while($contextClass->getName()!==$ownerClassName){$contextClass=$contextClass->getParentClass();}if($contextClass->getName()!==$ownerClassName){ throw new Exception('Attempting to call protected method in an invalid context');}$method->setAccessible(true);}}else {$invokeContext=$func[0];}break;default:$contextClass=new ReflectionClass($backtrace[$contextKey]['object']);$method=new ReflectionMethod($func[1],$func[0]);$ownerClassName=$method->getDeclaringClass()->getName();if(!$method->isStatic()){ throw new Exception('Attempting to call instance method in a static context');}$invokeContext=null;if($method->isPrivate()){if(empty($backtrace[$contextKey]['object'])||$func[0]!==$contextClass->getName()||!method_exists($method,'setAccessible')){ throw new Exception('Attempting to call private method in an invalid context');}$method->setAccessible(true);}else if($method->isProtected()){$contextClass=new ReflectionClass($backtrace[$contextKey]['object']);if(empty($backtrace[$contextKey]['object'])||!method_exists($method,'setAccessible')){ throw new Exception('Attempting to call protected method outside a class context');}while($contextClass->getName()!==$ownerClassName){$contextClass=$contextClass->getParentClass();}if($contextClass->getName()!==$ownerClassName){ throw new Exception('Attempting to call protected method in an invalid context');}$method->setAccessible(true);}break;}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('static','getName'));} private static function getName(){return 'Car';}}class Toyota extends Car{ public static function getName(){return 'Toyota';}}$car=new Car();echo $car->run();$toyota=new Toyota();echo $toyota->run();

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.0070.01019.02
8.3.30.0150.00020.26
8.3.20.0000.00820.51
8.3.10.0040.00421.97
8.3.00.0000.00822.40
8.2.170.0120.00622.96
8.2.160.0140.00422.26
8.2.150.0030.00524.18
8.2.140.0060.00324.66
8.2.130.0090.00926.16
8.2.120.0030.00517.63
8.2.110.0040.00422.02
8.2.100.0030.00917.84
8.2.90.0080.00019.30
8.2.80.0060.00319.46
8.2.70.0030.00617.88
8.2.60.0040.00418.05
8.2.50.0000.01018.07
8.2.40.0050.00318.34
8.2.30.0080.00018.21
8.2.20.0000.00817.78
8.2.10.0080.00017.95
8.2.00.0030.00617.93
8.1.270.0000.00824.66
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0100.00323.91
8.1.230.0000.01119.27
8.1.220.0050.00317.91
8.1.210.0040.00418.77
8.1.200.0030.00617.48
8.1.190.0080.00017.66
8.1.180.0040.00818.10
8.1.170.0040.00418.60
8.1.160.0040.00419.01
8.1.150.0080.00018.83
8.1.140.0040.00417.53
8.1.130.0040.00417.89
8.1.120.0000.00817.48
8.1.110.0040.00417.46
8.1.100.0070.00017.55
8.1.90.0000.00717.52
8.1.80.0050.00217.63
8.1.70.0050.00317.48
8.1.60.0000.00817.74
8.1.50.0000.00917.55
8.1.40.0040.00417.54
8.1.30.0040.00417.73
8.1.20.0030.00617.68
8.1.10.0040.00417.64
8.1.00.0000.01117.65
8.0.300.0080.00018.77
8.0.290.0060.00317.30
8.0.280.0040.00418.59
8.0.270.0000.00717.34
8.0.260.0000.00717.00
8.0.250.0000.00716.98
8.0.240.0000.00817.09
8.0.230.0070.00016.98
8.0.220.0040.00417.10
8.0.210.0050.00316.90
8.0.200.0000.00817.07
8.0.190.0040.00417.01
8.0.180.0000.00817.10
8.0.170.0040.00416.94
8.0.160.0000.00717.01
8.0.150.0080.00017.02
8.0.140.0060.00316.93
8.0.130.0030.00313.53
8.0.120.0040.00417.05
8.0.110.0040.00416.95
8.0.100.0050.00316.85
8.0.90.0050.00316.87
8.0.80.0070.00816.92
8.0.70.0040.00416.99
8.0.60.0030.00617.08
8.0.50.0040.00416.99
8.0.30.0070.01717.28
8.0.20.0120.00717.41
8.0.10.0040.00416.95
8.0.00.0100.00816.68
7.4.330.0000.00615.00
7.4.320.0060.00016.75
7.4.300.0060.00016.63
7.4.290.0000.00816.67
7.4.280.0070.00016.77
7.4.270.0000.00816.56
7.4.260.0060.00013.36
7.4.250.0040.00416.56
7.4.240.0020.00616.72
7.4.230.0000.00716.84
7.4.220.0030.01816.76
7.4.210.0060.00916.62
7.4.200.0000.00716.85
7.4.190.0040.00416.64
7.4.160.0080.01116.55
7.4.150.0060.01217.40
7.4.140.0100.01017.86
7.4.130.0030.01516.69
7.4.120.0160.00116.77
7.4.110.0100.01016.72
7.4.100.0100.00716.78
7.4.90.0130.00616.82
7.4.80.0080.01219.39
7.4.70.0070.01016.52
7.4.60.0070.01716.67
7.4.50.0000.00816.37
7.4.40.0070.01022.77
7.4.30.0100.00716.55
7.4.10.0120.00614.93
7.4.00.0050.01215.12
7.3.330.0000.00513.29
7.3.320.0050.00013.25
7.3.310.0030.00316.50
7.3.300.0070.00016.42
7.3.290.0030.01616.42
7.3.280.0060.00916.52
7.3.270.0030.01417.40
7.3.260.0040.01516.38
7.3.250.0070.01016.58
7.3.240.0100.01016.78
7.3.230.0030.01416.48
7.3.210.0000.01716.71
7.3.200.0150.00819.39
7.3.190.0100.00816.82
7.3.180.0070.01016.68
7.3.170.0110.00716.55
7.3.160.0110.00716.56
7.3.130.0130.00615.14
7.3.120.0070.00915.19
7.3.110.0080.01114.82
7.3.100.0060.00915.22
7.3.90.0000.01315.05
7.3.80.0070.00715.25
7.3.70.0090.00015.14
7.3.60.0000.01115.06
7.3.50.0040.01214.84
7.3.40.0090.00914.88
7.3.30.0000.01014.99
7.3.20.0060.01216.51
7.3.10.0050.01216.51
7.3.00.0050.01216.63
7.2.330.0150.00316.86
7.2.320.0160.00216.59
7.2.310.0110.01116.83
7.2.300.0110.00916.79
7.2.290.0090.01216.96
7.2.260.0130.00615.15
7.2.250.0150.00015.18
7.2.240.0030.00914.98
7.2.230.0070.00715.20
7.2.220.0120.00414.98
7.2.210.0030.00915.18
7.2.200.0040.01115.40
7.2.190.0000.01014.84
7.2.180.0040.01115.16
7.2.170.0070.01015.28
7.2.160.0070.00315.25
7.2.150.0070.00316.92
7.2.140.0000.01516.91
7.2.130.0030.01216.87
7.2.120.0080.01016.91
7.2.110.0050.01117.03
7.2.100.0130.00516.71
7.2.90.0090.00816.86
7.2.80.0070.00816.93
7.2.70.0140.00716.95
7.2.60.0060.00816.96
7.2.50.0070.00717.03
7.2.40.0130.00816.81
7.2.30.0030.01016.97
7.2.20.0090.00616.85
7.2.10.0120.00816.95
7.2.00.0100.00717.78
7.1.330.0070.00315.63
7.1.320.0040.00815.60
7.1.310.0030.00915.96
7.1.300.0000.00915.84
7.1.290.0130.00715.86
7.1.280.0100.00716.02
7.1.270.0100.00315.92
7.1.260.0000.01416.04
7.1.250.0070.00815.56
7.1.240.0040.01115.97
7.1.230.0040.00815.90
7.1.220.0070.00715.66
7.1.210.0060.00615.46
7.1.200.0060.00915.97
7.1.190.0050.00515.90
7.1.180.0000.01415.87
7.1.170.0060.00315.98
7.1.160.0030.01315.71
7.1.150.0060.00615.99
7.1.140.0030.00915.83
7.1.130.0060.00315.89
7.1.120.0100.00315.91
7.1.110.0060.00915.83
7.1.100.0060.00916.17
7.1.90.0040.01015.95
7.1.80.0040.00415.63
7.1.70.0060.00816.55
7.1.60.0080.01117.54
7.1.50.0090.00916.18
7.1.40.0030.01415.90
7.1.30.0100.00715.68
7.1.20.0080.00815.61
7.1.10.0070.01115.77
7.1.00.0050.04519.17
7.0.330.0070.00315.61
7.0.320.0040.01115.28
7.0.310.0060.00615.41
7.0.300.0090.00015.43
7.0.290.0030.00715.41
7.0.280.0030.00915.21
7.0.270.0060.00915.46
7.0.260.0040.00715.29
7.0.250.0000.00915.48
7.0.240.0070.00715.61
7.0.230.0060.00615.47
7.0.220.0110.00315.23
7.0.210.0080.00815.57
7.0.200.0020.00916.19
7.0.190.0030.01015.46
7.0.180.0030.01315.39
7.0.170.0030.00715.45
7.0.160.0040.00715.44
7.0.150.0070.01015.31
7.0.140.0080.03818.78
7.0.130.0000.01515.55
7.0.120.0000.01415.60
7.0.110.0030.01215.24
7.0.100.0100.04017.93
7.0.90.0120.04017.64
7.0.80.0020.04917.75
7.0.70.0130.04117.74
7.0.60.0000.03717.75
7.0.50.0030.02717.99
7.0.40.0090.02116.86
7.0.30.0050.02516.80
7.0.20.0000.02816.64
7.0.10.0120.03716.91
7.0.00.0080.04016.82
5.6.400.0080.00814.34
5.6.390.0000.00914.30
5.6.380.0030.01214.45
5.6.370.0090.00914.38
5.6.360.0040.01114.72
5.6.350.0130.00314.17
5.6.340.0120.00014.66
5.6.330.0040.01114.77
5.6.320.0080.00414.32
5.6.310.0150.00014.41
5.6.300.0030.01414.83
5.6.290.0090.00914.64
5.6.280.0040.04117.73
5.6.270.0070.00714.64
5.6.260.0030.01014.40
5.6.250.0070.04317.62
5.6.240.0070.04217.69
5.6.230.0090.04917.51
5.6.220.0030.03517.79
5.6.210.0020.04717.62
5.6.200.0010.02817.95
5.6.190.0100.02217.85
5.6.180.0050.01917.96
5.6.170.0020.02917.74
5.6.160.0080.02817.80
5.6.150.0040.04717.72
5.6.140.0070.03917.80
5.6.130.0070.02317.87
5.6.120.0030.03317.80
5.6.110.0030.02917.75
5.6.100.0030.02717.88
5.6.90.0050.02717.87
5.6.80.0050.02617.61
5.6.70.0080.02317.43
5.6.60.0020.02117.36
5.6.50.0030.02817.42
5.6.40.0020.02217.34
5.6.30.0030.02217.38
5.6.20.0060.02917.57
5.6.10.0100.01717.63
5.6.00.0080.04117.38
5.5.380.0110.04317.56
5.5.370.0030.04617.53
5.5.360.0050.04317.56
5.5.350.0050.03617.38
5.5.340.0050.02517.51
5.5.330.0020.02817.60
5.5.320.0040.02717.67
5.5.310.0030.02617.63
5.5.300.0100.03717.57
5.5.290.0080.02317.53
5.5.280.0060.02517.67
5.5.270.0090.02217.49
5.5.260.0110.03117.65
5.5.250.0060.02117.60
5.5.240.0080.02017.21
5.5.230.0120.01617.37
5.5.220.0050.02217.40
5.5.210.0050.03017.23
5.5.200.0030.02417.42
5.5.190.0060.02717.27
5.5.180.0040.02317.23
5.5.170.0000.01714.60
5.5.160.0020.03117.33
5.5.150.0100.04217.32
5.5.140.0090.04017.39
5.5.130.0090.03817.22
5.5.120.0050.04017.23
5.5.110.0120.04517.13
5.5.100.0080.04317.24
5.5.90.0080.04317.38
5.5.80.0090.03917.18
5.5.70.0080.03817.11
5.5.60.0080.03817.14
5.5.50.0090.03417.10
5.5.40.0030.02817.39
5.5.30.0100.03817.39
5.5.20.0030.03617.21
5.5.10.0030.04317.07
5.5.00.0050.02217.26
5.4.450.0000.02616.06
5.4.440.0050.03316.05
5.4.430.0020.02615.87
5.4.420.0030.02115.92
5.4.410.0020.02415.93
5.4.400.0080.02015.84
5.4.390.0070.02915.76
5.4.380.0100.01315.89
5.4.370.0070.02015.77
5.4.360.0020.02315.91
5.4.350.0020.02215.88
5.4.340.0100.03715.86
5.4.330.0090.00012.57
5.4.320.0050.02015.74
5.4.310.0080.03815.81
5.4.300.0070.04115.76
5.4.290.0080.01715.83
5.4.280.0050.03715.71
5.4.270.0050.04115.90
5.4.260.0050.04215.73
5.4.250.0070.03415.91
5.4.240.0070.04015.83
5.4.230.0030.04215.85
5.4.220.0060.04115.79
5.4.210.0020.04515.84
5.4.200.0020.02315.73
5.4.190.0090.01615.80
5.4.180.0070.03915.83
5.4.170.0070.03915.90
5.4.160.0060.02515.79
5.4.150.0050.03715.87
5.4.140.0030.04114.53
5.4.130.0070.02714.40
5.4.120.0070.03714.49
5.4.110.0090.03814.54
5.4.100.0040.02714.51
5.4.90.0030.03814.51
5.4.80.0080.03814.47
5.4.70.0040.04214.56
5.4.60.0050.04014.52
5.4.50.0050.02614.56
5.4.40.0080.02314.54
5.4.30.0070.02414.48
5.4.20.0060.03714.46
5.4.10.0100.03014.42
5.4.00.0070.03614.26
5.3.290.0040.03613.66
5.3.280.0020.04313.65
5.3.270.0020.02413.66
5.3.260.0000.04113.66
5.3.250.0090.03013.63
5.3.240.0070.03413.64
5.3.230.0110.03513.68
5.3.220.0050.04213.62
5.3.210.0100.03713.64
5.3.200.0070.03513.64
5.3.190.0100.03813.60
5.3.180.0030.04413.63
5.3.170.0000.04413.59
5.3.160.0030.04313.61
5.3.150.0050.04313.56
5.3.140.0060.03113.67
5.3.130.0100.02013.58
5.3.120.0020.02413.56
5.3.110.0110.03713.59
5.3.100.0090.03913.41
5.3.90.0070.04013.33
5.3.80.0050.05013.39
5.3.70.0070.03813.37
5.3.60.0030.02913.27
5.3.50.0030.04313.32
5.3.40.0060.03313.27
5.3.30.0100.01813.32
5.3.20.0080.03813.14
5.3.10.0040.03613.20
5.3.00.0080.03913.10

preferences:
45.98 ms | 400 KiB | 5 Q