3v4l.org

run code in 300+ PHP versions simultaneously
<?php $mf = function () { /** * Used to store functions and allow recursive callbacks. * @var null|callback */ static $deploy = null; /** * Defined matches. * @var array */ static $ms = array(); /** * Dependency Injection callbacks, used for settings too. * @var array */ static $di = array(); // used to shorten code $num_args = func_num_args(); $get_args = func_get_args(); // used to retrieve currently defined matches // http://www.php.net/manual/en/regexp.reference.conditional.php // http://stackoverflow.com/questions/14598972/catch-all-regular-expression if ($num_args === 0 && PHP_SAPI !== 'cli') { return '/?(?!(' . implode('|', $ms) . ')$).*'; } elseif ($num_args === 2 && preg_match('#^[^/].+#', $get_args[0])) { // functions used for Dependency Injection and settings return $di[$get_args[0]] = $get_args[1]; } elseif ($num_args === 1 && preg_match('#^[^/].+#', $get_args[0])) { return is_callable($di[$get_args[0]]) ? call_user_func($di[$get_args[0]]) : $di[$get_args[0]]; } // functions have to be stored only once if (is_null($deploy) && PHP_SAPI === 'cli') { /** * Command line interface for the main function. * * @link http://php.net/manual/en/language.types.float.php * * @param callback $callback Function invoked when script ends * @param integer $priority Set `$callback` priority from 0 (high) to ~1.8e308 (low) * @return void */ $deploy = function ($callback, $priority = 0) use (&$deploy) { /** * Checking well formed call */ assert(is_callable($callback)); assert(is_numeric($priority)); /** * Arguments passed to the script. * @link http://php.net/manual/en/reserved.variables.argv.php * @var array */ $argv = $GLOBALS['argv']; if ($priority > 0) { /** * Recursion is used to set callback priority */ register_shutdown_function($deploy, $callback, $priority - 1); } else { $argv[0] = $callback; /** * register_shutdown_function is used to call added functions when script ends * @link http://it2.php.net/manual/en/function.register-shutdown-function.php */ call_user_func_array('register_shutdown_function', $argv); } }; } elseif (is_null($deploy)) { /** * Function used as a router. * * @link http://php.net/manual/en/language.types.float.php * * @param string $regex Regular expression used to match requested URL * @param callback $callback Function invoked when there's a match * @param string $method Request method(s) * @param float $priority Set `$callback` priority from 0 (high) to ~1.8e308 (low) * @return void */ $deploy = function ($regex, $callback, $method = 'GET', $priority = 0) use (&$deploy, &$ms) { /** * Checking well formed call */ assert(is_string($regex)); assert(is_callable($callback)); assert(is_string($method)); assert(is_numeric($priority)); // match stored as unique $ms[md5($regex)] = $regex; if ($priority > 0) { /** * Recursion is used to set callback priority */ register_shutdown_function($deploy, $regex, $callback, $method, $priority - 1); } elseif (preg_match('#' . $method . '#', $_SERVER['REQUEST_METHOD'])) { if (preg_match('#^' . $regex . '$#', $_SERVER['REQUEST_URI'], $matches)) { /** * Named subpatterns aren't allowed * @link http://it2.php.net/manual/en/regexp.reference.subpatterns.php */ while (list($key) = each($matches)) { if (!is_int($key)) { unset($matches[$key]); } } /** * Closure is added to `register_shutdown_function` calling */ if (isset($matches[0]) && $matches[0] === $_SERVER['REQUEST_URI']) { $matches[0] = $callback; } else { array_unshift($matches, $callback); } /** * register_shutdown_function is used to call added functions when script ends * @link http://it2.php.net/manual/en/function.register-shutdown-function.php */ call_user_func_array('register_shutdown_function', $matches); } } }; } return call_user_func_array($deploy, func_get_args()); }; assert_options(ASSERT_ACTIVE, 1); assert_options(ASSERT_BAIL, 1); $mf('/.*', function () { echo "Hello "; }); $mf('/.*', function () { echo "World!"; });

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.0090.00618.93
8.3.30.0120.00319.22
8.3.20.0000.00820.16
8.3.10.0060.00323.62
8.3.00.0000.01117.88
8.2.170.0060.00922.96
8.2.160.0030.01020.64
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0080.00022.11
8.2.110.0040.00422.30
8.2.100.0060.00618.16
8.2.90.0060.00319.52
8.2.80.0050.00318.16
8.2.70.0080.00018.00
8.2.60.0040.00418.16
8.2.50.0000.00918.07
8.2.40.0030.00618.28
8.2.30.0000.00818.29
8.2.20.0070.00017.95
8.2.10.0000.00718.12
8.2.00.0060.00618.03
8.1.270.0080.00023.89
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0030.00623.83
8.1.230.0100.00019.22
8.1.220.0000.00817.88
8.1.210.0030.00618.77
8.1.200.0070.00317.73
8.1.190.0040.00417.66
8.1.180.0040.00418.10
8.1.170.0040.00418.75
8.1.160.0050.00222.16
8.1.150.0040.00418.88
8.1.140.0040.00417.66
8.1.130.0000.00817.85
8.1.120.0000.00717.67
8.1.110.0040.00417.64
8.1.100.0000.00717.67
8.1.90.0000.00717.57
8.1.80.0040.00417.70
8.1.70.0000.00717.64
8.1.60.0030.00617.79
8.1.50.0000.00817.73
8.1.40.0050.00317.74
8.1.30.0030.00517.80
8.1.20.0000.00817.88
8.1.10.0000.00817.79
8.1.00.0040.00417.79
8.0.300.0040.00419.15
8.0.290.0070.00017.30
8.0.280.0030.00318.55
8.0.270.0000.00717.36
8.0.260.0040.00417.43
8.0.250.0070.00017.27
8.0.240.0080.00017.21
8.0.230.0040.00417.23
8.0.220.0070.00017.04
8.0.210.0070.00017.22
8.0.200.0050.00317.23
8.0.190.0000.00917.32
8.0.180.0070.00017.13
8.0.170.0000.00817.13
8.0.160.0040.00417.14
8.0.150.0040.00417.09
8.0.140.0000.00717.14
8.0.130.0070.00013.55
8.0.120.0080.00017.11
8.0.110.0040.00417.07
8.0.100.0050.00217.05
8.0.90.0000.00817.16
8.0.80.0120.00317.14
8.0.70.0030.00617.07
8.0.60.0000.00817.01
8.0.50.0000.00717.18
8.0.30.0090.01317.31
8.0.20.0110.00717.40
8.0.10.0040.00417.37
8.0.00.0090.00917.07
7.4.330.0030.00315.02
7.4.320.0000.00716.89
7.4.300.0000.00616.92
7.4.290.0080.00016.81
7.4.280.0050.00216.79
7.4.270.0000.00716.93
7.4.260.0030.00516.87
7.4.250.0080.00016.82
7.4.240.0020.00616.89
7.4.230.0000.00716.87
7.4.220.0100.01616.91
7.4.210.0090.00716.85
7.4.200.0030.00316.59
7.4.190.0040.00416.85
7.4.160.0090.00616.72
7.4.150.0120.00617.40
7.4.140.0120.00717.86
7.4.130.0080.01016.99
7.4.120.0110.00716.86
7.4.110.0060.01216.93
7.4.100.0120.01216.85
7.4.90.0030.01816.86
7.4.80.0040.01519.39
7.4.70.0040.01816.75
7.4.60.0030.01316.56
7.4.50.0030.00616.65
7.4.40.0050.00822.77
7.4.30.0060.00916.78
7.4.00.0090.00615.35
7.3.330.0000.00513.67
7.3.320.0070.00013.71
7.3.310.0070.00016.71
7.3.300.0000.00716.70
7.3.290.0040.01116.64
7.3.280.0080.01016.64
7.3.270.0130.00817.40
7.3.260.0100.01016.90
7.3.250.0090.00916.71
7.3.240.0120.00616.69
7.3.230.0140.00316.74
7.3.210.0030.01416.96
7.3.200.0150.00319.39
7.3.190.0100.01016.95
7.3.180.0090.01016.63
7.3.170.0060.00916.67
7.3.160.0130.00316.81
7.3.120.0100.00415.14
7.3.110.0100.00515.14
7.3.100.0070.00815.37
7.3.90.0120.00315.35
7.3.80.0060.00815.17
7.3.70.0020.00915.19
7.3.60.0020.01415.10
7.3.50.0040.00915.12
7.3.40.0060.00515.03
7.3.30.0070.00615.17
7.3.20.0060.00616.98
7.3.10.0000.01216.82
7.3.00.0100.00316.88
7.2.330.0070.01016.89
7.2.320.0080.01416.85
7.2.310.0080.01116.93
7.2.300.0030.01416.72
7.2.290.0070.01017.07
7.2.240.0060.00915.17
7.2.230.0050.00715.44
7.2.220.0110.00515.32
7.2.210.0070.00815.40
7.2.200.0050.01215.13
7.2.190.0080.00515.41
7.2.180.0020.01215.35
7.2.170.0050.00915.27
7.2.160.0090.00715.24
7.2.150.0050.01017.13
7.2.140.0080.00617.08
7.2.130.0090.00417.19
7.2.120.0080.00817.00
7.2.110.0070.00716.95
7.2.100.0030.01317.13
7.2.90.0060.00517.21
7.2.80.0050.00817.00
7.2.70.0090.00316.96
7.2.60.0060.00817.12
7.2.50.0060.00617.28
7.2.40.0040.00917.13
7.2.30.0030.01017.17
7.2.20.0050.00817.23
7.2.10.0050.00817.10
7.2.00.0040.01218.08
7.1.330.0080.00615.82
7.1.320.0080.00716.13
7.1.310.0020.00916.04
7.1.300.0020.00815.92
7.1.290.0060.00515.80
7.1.280.0110.00316.04
7.1.270.0040.00815.98
7.1.260.0030.01016.08
7.1.250.0030.00915.95
7.1.200.0030.00815.94
7.1.100.0030.00918.14
7.1.70.0000.00817.49
7.1.60.0060.01219.33
7.1.50.0200.01335.11
7.1.00.0130.06722.45
7.0.200.0000.01116.95
7.0.140.0030.07322.08
7.0.100.0030.04319.99
7.0.90.0170.08020.01
7.0.80.0300.07720.06
7.0.70.0000.08719.99
7.0.60.0000.07020.12
7.0.50.0030.08020.29
7.0.40.0170.03720.07
7.0.30.0130.04320.04
7.0.20.0070.05020.14
7.0.10.0070.08020.14
7.0.00.0100.06720.18
5.6.280.0030.07321.07
5.6.250.0100.04320.86
5.6.240.0030.07020.77
5.6.230.0030.08720.71
5.6.220.0070.08020.73
5.6.210.0070.08320.69
5.6.200.0070.07021.07
5.6.190.0070.05021.13
5.6.180.0070.08321.03
5.6.170.0070.07021.09
5.6.160.0030.09021.09
5.6.150.0170.06321.04
5.6.140.0070.08021.00
5.6.130.0130.07321.11
5.6.120.0070.05321.05
5.6.110.0030.07321.05
5.6.100.0170.07721.03
5.6.90.0100.05721.04
5.6.80.0070.08320.36
5.6.70.0200.07020.53
5.6.60.0070.07020.49
5.6.50.0000.08320.51
5.6.40.0000.04720.51
5.6.30.0030.04720.48
5.6.20.0030.08720.41
5.6.10.0170.07020.48
5.6.00.0070.06720.44
5.5.380.0100.06020.54
5.5.370.0100.08020.61
5.5.360.0070.05720.41
5.5.350.0170.07720.38
5.5.340.0000.08320.96
5.5.330.0070.08720.84
5.5.320.0070.07320.69
5.5.310.0200.06720.85
5.5.300.0070.07320.85
5.5.290.0100.07720.93
5.5.280.0070.09020.94
5.5.270.0070.08720.77
5.5.260.0070.08020.77
5.5.250.0030.08720.75
5.5.240.0070.08320.35
5.5.230.0070.04320.30
5.5.220.0000.04720.24
5.5.210.0030.08720.34
5.5.200.0070.07720.32
5.5.190.0030.07320.22
5.5.180.0070.08020.25
5.5.160.0200.06720.04
5.5.150.0130.06720.26
5.5.140.0000.08720.30
5.5.130.0100.05720.16
5.5.120.0070.07720.25
5.5.110.0130.07320.26
5.5.100.0070.08020.16
5.5.90.0070.07020.02
5.5.80.0170.07019.98
5.5.70.0070.09020.10
5.5.60.0030.07720.18
5.5.50.0030.06720.20
5.5.40.0070.07019.98
5.5.30.0070.08020.20
5.5.20.0070.08020.12
5.5.10.0070.04720.07
5.5.00.0000.08319.99
5.4.450.0030.07719.37
5.4.440.0030.04719.17
5.4.430.0100.06319.37
5.4.420.0070.08019.46
5.4.410.0070.08019.25
5.4.400.0100.06319.13
5.4.390.0070.08019.13
5.4.380.0100.03019.18
5.4.370.0030.08319.23
5.4.360.0130.06318.85
5.4.350.0070.04319.18
5.4.340.0030.04319.18
5.4.320.0130.07719.13
5.4.310.0100.06019.09
5.4.300.0030.08018.95
5.4.290.0070.07319.23
5.4.280.0030.07719.04
5.4.270.0100.07318.89
5.4.260.0070.06719.16
5.4.250.0100.07019.12
5.4.240.0100.03719.04
5.4.230.0070.08019.08
5.4.220.0130.07319.09
5.4.210.0070.05719.20
5.4.200.0100.07318.88
5.4.190.0000.05019.11
5.4.180.0070.07718.93
5.4.170.0000.08319.03
5.4.160.0130.06719.11
5.4.150.0130.07319.21
5.4.140.0070.06016.48
5.4.130.0070.07316.26
5.4.120.0100.05716.48
5.4.110.0100.07016.55
5.4.100.0030.08016.52
5.4.90.0100.06716.39
5.4.80.0030.04316.40
5.4.70.0030.06016.47
5.4.60.0100.07316.42
5.4.50.0100.07016.41
5.4.40.0030.05316.37
5.4.30.0030.07716.54
5.4.20.0030.04316.47
5.4.10.0070.07016.49
5.4.00.0030.07315.64
5.3.290.0030.08314.71
5.3.280.0070.07714.60
5.3.270.0100.07314.68
5.3.260.0070.06714.76
5.3.250.0030.08014.73
5.3.240.0070.07714.73
5.3.230.0030.07314.70
5.3.220.0130.03714.65
5.3.210.0070.07014.69
5.3.200.0100.06314.63
5.3.190.0000.07314.74
5.3.180.0170.06314.72
5.3.170.0100.07014.55
5.3.160.0070.04314.66
5.3.150.0130.07014.63
5.3.140.0070.04314.64
5.3.130.0130.07014.65
5.3.120.0100.07314.65
5.3.110.0030.04014.61
5.3.100.0070.07714.02
5.3.90.0070.07314.20
5.3.80.0100.07014.16
5.3.70.0000.04314.12
5.3.60.0070.04014.04
5.3.50.0030.05713.99
5.3.40.0070.07714.08
5.3.30.0100.07013.87
5.3.20.0100.04013.82
5.3.10.0070.07013.66
5.3.00.0070.04713.76
5.2.170.0030.04011.79
5.2.160.0030.05011.79
5.2.150.0030.04311.79
5.2.140.0100.05311.79
5.2.130.0030.06011.79
5.2.120.0070.05011.79
5.2.110.0030.06711.79
5.2.100.0000.04311.79
5.2.90.0070.03711.79
5.2.80.0030.05311.79
5.2.70.0070.06011.79
5.2.60.0100.05711.79
5.2.50.0030.05711.79
5.2.40.0030.04711.79
5.2.30.0030.05711.79
5.2.20.0030.06011.79
5.2.10.0100.03311.79
5.2.00.0070.02711.79
5.1.60.0030.03011.79
5.1.50.0070.05011.79
5.1.40.0030.04311.79
5.1.30.0070.05011.79
5.1.20.0100.05011.79
5.1.10.0030.04711.79
5.1.00.0070.03711.79
5.0.50.0070.04311.79
5.0.40.0070.03311.79
5.0.30.0000.03711.79
5.0.20.0000.04711.79
5.0.10.0030.02311.79
5.0.00.0070.06311.79
4.4.90.0000.02311.79
4.4.80.0070.02011.79
4.4.70.0070.03311.79
4.4.60.0000.02711.79
4.4.50.0000.03711.79
4.4.40.0030.04711.79
4.4.30.0100.02311.79
4.4.20.0030.03311.79
4.4.10.0070.03311.79
4.4.00.0000.05011.79
4.3.110.0000.03311.79
4.3.100.0070.01311.79
4.3.90.0030.03311.79
4.3.80.0000.04311.79
4.3.70.0030.03311.79
4.3.60.0000.01711.79
4.3.50.0030.03311.79
4.3.40.0070.04011.79
4.3.30.0000.02011.79
4.3.20.0030.03311.79
4.3.10.0000.02011.79
4.3.00.0000.03311.79

preferences:
46.8 ms | 400 KiB | 5 Q