3v4l.org

run code in 300+ PHP versions simultaneously
<?php // error handler function function myErrorHandler($errno, $errstr, $errfile, $errline) { if (!(error_reporting() & $errno)) { // This error code is not included in error_reporting return; } switch ($errno) { case E_USER_ERROR: echo "<b>My ERROR</b> [$errno] $errstr<br />\n"; echo " Fatal error on line $errline in file $errfile"; echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n"; echo "Aborting...<br />\n"; exit(1); break; case E_USER_WARNING: echo "<b>My WARNING</b> [$errno] $errstr<br />\n"; break; case E_USER_NOTICE: echo "<b>My NOTICE</b> [$errno] $errstr<br />\n"; break; default: echo "Unknown error type: [$errno] $errstr<br />\n"; break; } /* Don't execute PHP internal error handler */ return true; } // function to test the error handling function scale_by_log($vect, $scale) { if (!is_numeric($scale) || $scale <= 0) { trigger_error("log(x) for x <= 0 is undefined, you used: scale = $scale", E_USER_ERROR); } if (!is_array($vect)) { trigger_error("Incorrect input vector, array of values expected", E_USER_WARNING); return null; } $temp = array(); foreach($vect as $pos => $value) { if (!is_numeric($value)) { trigger_error("Value at position $pos is not a number, using 0 (zero)", E_USER_NOTICE); $value = 0; } $temp[$pos] = log($scale) * $value; } return $temp; } // set to the user defined error handler $old_error_handler = set_error_handler("myErrorHandler"); // trigger some errors, first define a mixed array with a non-numeric item echo "vector a\n"; $a = array(2, 3, "foo", 5.5, 43.3, 21.11); print_r($a); // now generate second array echo "----\nvector b - a notice (b = log(PI) * a)\n"; /* Value at position $pos is not a number, using 0 (zero) */ $b = scale_by_log($a, M_PI); print_r($b); // this is trouble, we pass a string instead of an array echo "----\nvector c - a warning\n"; /* Incorrect input vector, array of values expected */ $c = scale_by_log("not array", 2.3); var_dump($c); // NULL // this is a critical error, log of zero or negative number is undefined echo "----\nvector d - fatal error\n"; /* log(x) for x <= 0 is undefined, you used: scale = $scale" */ $d = scale_by_log($a, -2.5); var_dump($d); // Never reached ?>

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.0140.00018.93
8.3.30.0120.00318.96
8.3.20.0090.00018.98
8.3.10.0080.00020.78
8.3.00.0080.00019.50
8.2.170.0080.00822.96
8.2.160.0120.00321.33
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0110.00426.16
8.2.120.0080.00021.08
8.2.110.0030.00721.19
8.2.100.0040.01217.84
8.2.90.0080.00319.52
8.2.80.0050.00319.46
8.2.70.0030.00517.88
8.2.60.0050.00518.18
8.2.50.0040.00418.07
8.2.40.0030.00618.34
8.2.30.0060.00318.32
8.2.20.0040.00417.87
8.2.10.0000.00817.91
8.2.00.0030.00517.86
8.1.270.0030.00524.66
8.1.260.0080.00026.35
8.1.250.0000.00728.09
8.1.240.0060.00322.75
8.1.230.0080.00421.04
8.1.220.0090.00017.90
8.1.210.0080.00019.10
8.1.200.0060.00317.60
8.1.190.0000.00817.73
8.1.180.0000.00818.10
8.1.170.0000.00819.02
8.1.160.0040.00419.08
8.1.150.0050.00318.89
8.1.140.0040.00417.70
8.1.130.0070.00018.09
8.1.120.0040.00417.71
8.1.110.0000.00717.66
8.1.100.0000.00717.58
8.1.90.0030.00617.70
8.1.80.0000.00717.70
8.1.70.0070.00017.64
8.1.60.0040.00417.77
8.1.50.0050.00317.55
8.1.40.0000.00817.70
8.1.30.0060.00317.80
8.1.20.0000.00817.75
8.1.10.0000.00917.79
8.1.00.0040.00417.57
8.0.300.0040.00420.16
8.0.290.0040.00416.88
8.0.280.0050.00218.55
8.0.270.0030.00317.54
8.0.260.0040.00416.97
8.0.250.0040.00417.07
8.0.240.0070.00017.21
8.0.230.0030.00517.10
8.0.220.0030.00417.13
8.0.210.0000.00717.05
8.0.200.0070.00317.16
8.0.190.0050.00317.20
8.0.180.0000.00717.07
8.0.170.0040.00417.20
8.0.160.0040.00417.23
8.0.150.0050.00517.06
8.0.140.0030.00517.02
8.0.130.0060.00013.54
8.0.120.0040.00417.07
8.0.110.0020.00517.15
8.0.100.0000.00717.03
8.0.90.0000.00917.14
8.0.80.0100.00517.04
8.0.70.0040.00416.94
8.0.60.0000.00817.09
8.0.50.0040.00417.11
8.0.30.0150.00617.22
8.0.20.0110.01117.16
8.0.10.0070.00017.31
8.0.00.0050.01316.91
7.4.330.0000.00613.18
7.4.320.0040.00416.84
7.4.300.0030.00316.70
7.4.290.0070.00016.56
7.4.280.0070.00016.75
7.4.270.0070.00016.79
7.4.260.0040.00515.66
7.4.250.0050.00316.71
7.4.240.0040.00416.80
7.4.230.0000.00716.79
7.4.220.0100.00616.58
7.4.210.0090.00716.70
7.4.200.0000.00716.88
7.4.190.0050.00316.80
7.4.160.0140.00716.59
7.4.150.0100.00716.73
7.4.140.0100.00716.58
7.4.130.0140.00516.69
7.4.120.0100.01016.58
7.4.110.0090.00916.46
7.4.100.0030.01416.55
7.4.90.0170.00716.61
7.4.80.0070.01519.39
7.4.70.0060.01216.68
7.4.60.0040.01316.55
7.4.50.0090.00416.79
7.4.40.0030.00916.51
7.4.30.0130.00316.59
7.4.00.0090.00615.42
7.3.330.0000.00613.50
7.3.320.0000.00613.52
7.3.310.0000.00716.55
7.3.300.0030.00316.51
7.3.290.0070.00716.55
7.3.280.0060.01016.54
7.3.270.0030.01616.72
7.3.260.0080.01416.54
7.3.250.0100.01216.77
7.3.240.0060.01216.47
7.3.230.0150.00416.48
7.3.210.0130.00416.60
7.3.200.0060.01016.86
7.3.190.0100.01016.66
7.3.180.0140.00316.77
7.3.170.0090.00616.53
7.3.160.0080.00816.63
7.3.120.0070.00715.08
7.2.330.0130.00616.75
7.2.320.0000.01816.56
7.2.310.0120.00616.86
7.2.300.0070.01116.77
7.2.290.0100.01016.84
7.1.70.0040.00417.47
7.1.60.0070.01819.40
7.1.50.0120.01217.36
7.1.00.0070.03322.79
7.0.200.0050.00517.01
7.0.140.0070.07022.23
7.0.120.0070.07322.37
7.0.100.0230.06720.39
7.0.90.0400.06020.52
7.0.80.0270.05720.48
7.0.70.0300.05320.44
7.0.60.0430.07020.63
7.0.50.0470.06020.40
7.0.40.0270.05320.39
7.0.30.0370.05320.41
7.0.20.0370.05320.38
7.0.10.0400.07020.46
7.0.00.0500.06020.38
5.6.250.0130.07321.23
5.6.240.0000.07020.98
5.6.230.0130.05721.20
5.6.220.0100.05721.19
5.6.210.0130.05021.15
5.6.200.0100.07720.98
5.6.190.0230.05721.26
5.6.180.0270.05021.26
5.6.170.0170.05321.14
5.6.160.0200.05021.25
5.6.150.0170.05321.22
5.6.140.0030.06321.17
5.6.130.0170.04721.25
5.6.120.0030.06321.03
5.6.110.0130.08721.25
5.6.100.0170.05321.08
5.6.90.0070.05721.14
5.6.80.0070.06020.62
5.6.70.0200.04720.55
5.6.60.0130.05320.43
5.6.50.0270.04020.61
5.6.40.0130.05020.54
5.6.30.0200.05720.42
5.6.20.0170.07020.50
5.6.10.0130.04720.54
5.6.00.0100.06020.26
5.5.380.0030.06320.97
5.5.370.0130.06020.77
5.5.360.0130.07320.62
5.5.350.0070.06720.57
5.5.340.0030.06318.23
5.5.330.0030.06018.25
5.5.320.0070.06718.35
5.5.310.0070.05318.08
5.5.300.0030.05717.97
5.5.290.0070.07018.29
5.5.280.0100.05718.17
5.5.270.0030.06018.21
5.5.260.0070.07018.24
5.5.250.0100.05718.03
5.5.240.0200.05317.61
5.5.230.0170.05317.46
5.5.220.0070.05317.60
5.5.210.0130.04717.64
5.5.200.0130.04717.32
5.5.190.0030.05717.70
5.5.180.0070.06717.33
5.5.160.0200.06317.61
5.5.150.0170.06317.70
5.5.140.0130.04717.32
5.5.130.0030.05717.41
5.5.120.0100.05017.60
5.5.110.0030.05717.42
5.5.100.0130.04717.60
5.5.90.0070.05317.60
5.5.80.0170.05017.47
5.5.70.0070.05317.49
5.5.60.0100.05017.46
5.5.50.0170.04317.59
5.5.40.0070.05317.38
5.5.30.0100.05717.46
5.5.20.0200.04317.29
5.5.10.0070.05717.29
5.5.00.0130.05317.44
5.4.450.0230.07319.26
5.4.440.0100.07019.15
5.4.430.0130.06019.43
5.4.420.0100.05719.41
5.4.410.0130.04719.13
5.4.400.0130.06719.06
5.4.390.0070.05718.75
5.4.380.0070.06318.91
5.4.370.0130.05018.91
5.4.360.0230.04318.82
5.4.350.0100.07718.91
5.4.340.0030.05718.76
5.4.320.0170.05319.02
5.4.310.0100.05018.95
5.4.300.0100.05319.07
5.4.290.0100.05018.82
5.4.280.0130.06718.80
5.4.270.0130.06719.07
5.4.260.0170.04719.01
5.4.250.0030.05718.90
5.4.240.0130.05318.93
5.4.230.0100.05719.07
5.4.220.0230.06019.01
5.4.210.0230.03719.08
5.4.200.0130.04319.10
5.4.190.0070.05318.92
5.4.180.0100.05018.92
5.4.170.0070.07019.04
5.4.160.0130.06018.92
5.4.150.0100.07318.91
5.4.140.0130.04716.35
5.4.130.0030.07016.52
5.4.120.0000.05716.40
5.4.110.0070.05016.21
5.4.100.0170.04716.38
5.4.90.0170.04016.52
5.4.80.0130.06016.38
5.4.70.0000.06016.36
5.4.60.0130.05716.52
5.4.50.0100.05316.21
5.4.40.0030.05716.51
5.4.30.0100.06016.37
5.4.20.0200.07716.37
5.4.10.0170.05016.48
5.4.00.0130.05315.84
5.3.290.0270.05714.72
5.3.280.0230.03714.59
5.3.270.0070.05714.61
5.3.260.0100.05014.63
5.3.250.0000.06314.71
5.3.240.0100.05014.61
5.3.230.0070.06014.71
5.3.220.0170.05714.67
5.3.210.0170.06014.56
5.3.200.0070.05314.56
5.3.190.0100.05014.59
5.3.180.0170.05014.56
5.3.170.0170.05014.54
5.3.160.0230.06014.56
5.3.150.0130.04714.60
5.3.140.0130.04714.57
5.3.130.0070.07714.60
5.3.120.0030.07714.58
5.3.110.0100.05314.60
5.3.100.0130.04714.07
5.3.90.0100.05714.01
5.3.80.0200.06014.11
5.3.70.0100.06014.07
5.3.60.0100.04714.00
5.3.50.0130.06013.93
5.3.40.0030.05313.95
5.3.30.0030.05313.94
5.3.20.0170.04713.75
5.3.10.0270.03713.64
5.3.00.0130.04313.63
5.2.170.0130.04011.16
5.2.160.0170.03011.15
5.2.150.0130.03711.25
5.2.140.0100.03711.15
5.2.130.0000.04711.21
5.2.120.0130.03311.17
5.2.110.0030.04311.08
5.2.100.0070.03711.16
5.2.90.0070.04311.12
5.2.80.0000.04711.16
5.2.70.0100.04311.15
5.2.60.0000.05011.07
5.2.50.0100.03711.03
5.2.40.0100.03711.06
5.2.30.0030.04310.95
5.2.20.0100.03311.02
5.2.10.0100.03310.98
5.2.00.0070.03710.76
5.1.60.0030.0339.98
5.1.50.0070.03010.10
5.1.40.0100.0439.96
5.1.30.0070.03310.46
5.1.20.0070.05010.37
5.1.10.0030.04010.21
5.1.00.0170.02310.13
5.0.50.0070.0278.55
5.0.40.0100.0238.41
5.0.30.0100.0378.32
5.0.20.0030.0278.29
5.0.10.0070.0308.16
5.0.00.0100.0338.31
4.4.90.0000.0276.01
4.4.80.0000.0235.98
4.4.70.0030.0235.98
4.4.60.0030.0206.14
4.4.50.0000.0236.09
4.4.40.0000.0375.95
4.4.30.0030.0206.04
4.4.20.0000.0236.08
4.4.10.0030.0206.06
4.4.00.0070.0335.96
4.3.110.0100.0135.95
4.3.100.0030.0235.91
4.3.90.0070.0175.91
4.3.80.0070.0335.84
4.3.70.0030.0205.97
4.3.60.0000.0275.93
4.3.50.0000.0276.04
4.3.40.0030.0335.80
4.3.30.0000.0235.65
4.3.20.0000.0235.65
4.3.10.0030.0205.65
4.3.00.0000.0305.65

preferences:
37.3 ms | 400 KiB | 5 Q