3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Change me! $userSpecifiedPath = '/'; // works, HomepageController //$userSpecifiedPath = '/asdf'; // route doesn't exist, 404Controller $userSpecifiedPath = '/deep/nested/controller'; // // Don't edit below =============================================== // ================================================================ // Simple config example // ================================================================ $routerConfig = <<<CONFIG [/] Controller = "HomepageController" [/deep*] Controller = "DeepController" [404] Controller = "404Controller" CONFIG; // ================================================================ // Simple router example // ================================================================ class Router { private $routes; public function __construct($routes) { $this->routes = $routes; } public function getRouteFromPath($path) { if(array_key_exists($path, $this->routes) === true) { return $this->routes[$path]; } $hierarchical = $this->getHierarchicalRouteFromPath($path); if(!empty($hierarchical)) { return $hierarchical; } elseif(array_key_exists('404', $this->routes) === true) { return $this->routes['404']; } throw new Exception('No controllers found.'); } public function getAllHierarchicalRoutes() { $routes = array(); foreach($this->routes as $key => $route) { if(strpos($key, '*') === strlen($key) - 1) { $routes[$key] = $route; } } return $routes; } public function getHierarchicalRouteFromPath($path) { foreach($this->routes as $key => $route) { if(strpos($key, '*') === strlen($key) - 1) { if(strpos($path, rtrim($key, '*')) === 0) { return $route; } } } } } // ================================================================ // Sample output // ================================================================ $routes = parse_ini_string($routerConfig, true); $Router = new Router($routes); $selectedRoute = $Router->getRouteFromPath($userSpecifiedPath); echo 'Using controller: ' . $selectedRoute['Controller'];

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.0040.01218.30
8.3.50.0110.00721.92
8.3.40.0060.01318.79
8.3.30.0130.00319.18
8.3.20.0070.00020.21
8.3.10.0050.00322.05
8.3.00.0050.00322.18
8.2.180.0150.00016.88
8.2.170.0120.00622.96
8.2.160.0030.01021.07
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0080.00019.36
8.2.110.0070.00322.11
8.2.100.0090.00317.84
8.2.90.0000.00817.75
8.2.80.0040.00417.97
8.2.70.0040.00417.63
8.2.60.0040.00418.03
8.2.50.0000.00818.07
8.2.40.0040.00418.22
8.2.30.0040.00418.01
8.2.20.0020.00517.78
8.2.10.0000.00817.64
8.2.00.0000.00717.66
8.1.280.0140.00325.92
8.1.270.0050.00322.05
8.1.260.0080.00026.35
8.1.250.0000.00728.09
8.1.240.0130.00320.64
8.1.230.0110.00020.90
8.1.220.0090.00017.77
8.1.210.0080.00018.97
8.1.200.0030.00617.35
8.1.190.0050.00317.53
8.1.180.0030.00618.84
8.1.170.0000.00818.55
8.1.160.0000.00722.08
8.1.150.0000.00818.69
8.1.140.0030.00617.44
8.1.130.0030.00317.86
8.1.120.0000.00717.38
8.1.110.0030.00517.37
8.1.100.0040.00417.38
8.1.90.0050.00317.52
8.1.80.0000.00817.44
8.1.70.0040.00417.46
8.1.60.0000.00817.62
8.1.50.0040.00417.49
8.1.40.0040.00417.51
8.1.30.0060.00317.52
8.1.20.0050.00317.56
8.1.10.0000.00817.48
8.1.00.0050.00317.43
8.0.300.0040.00420.06
8.0.290.0070.00017.15
8.0.280.0000.00718.51
8.0.270.0040.00417.32
8.0.260.0000.00716.90
8.0.250.0000.00716.93
8.0.240.0040.00416.96
8.0.230.0030.00517.05
8.0.220.0070.00016.98
8.0.210.0030.00316.87
8.0.200.0000.00717.00
8.0.190.0000.00716.99
8.0.180.0040.00416.94
8.0.170.0000.00917.02
8.0.160.0070.00016.88
8.0.150.0000.00816.80
8.0.140.0040.00416.95
8.0.130.0060.00013.45
8.0.120.0040.00416.80
8.0.110.0040.00416.81
8.0.100.0000.00716.92
8.0.90.0040.00416.93
8.0.80.0070.01116.93
8.0.70.0000.00716.86
8.0.60.0000.00717.03
8.0.50.0050.00317.03
8.0.30.0100.00917.09
8.0.20.0100.01217.40
8.0.10.0000.00716.95
8.0.00.0100.00816.87
7.4.330.0050.00015.00
7.4.320.0030.00316.61
7.4.300.0030.00316.53
7.4.290.0060.00316.59
7.4.280.0060.00016.40
7.4.270.0040.00416.63
7.4.260.0000.00716.50
7.4.250.0000.00816.61
7.4.240.0090.00016.65
7.4.230.0030.00316.56
7.4.220.0060.01316.47
7.4.210.0070.00716.62
7.4.200.0000.00716.63
7.4.190.0030.00316.67
7.4.160.0130.00316.52
7.4.150.0160.00317.40
7.4.140.0140.00817.86
7.4.130.0160.00316.47
7.4.120.0090.01116.62
7.4.110.0110.00716.42
7.4.100.0100.00716.61
7.4.90.0030.01916.65
7.4.80.0120.00919.39
7.4.70.0080.00816.70
7.4.60.0110.00416.80
7.4.50.0080.00016.58
7.4.40.0070.00722.77
7.4.30.0100.00716.51
7.4.00.0070.01015.01
7.3.330.0000.00613.32
7.3.320.0030.00313.38
7.3.310.0000.00716.34
7.3.300.0060.00016.33
7.3.290.0120.00316.49
7.3.280.0080.00816.44
7.3.270.0140.00317.40
7.3.260.0090.01516.62
7.3.250.0100.01016.49
7.3.240.0160.00816.53
7.3.230.0120.00416.42
7.3.210.0080.01116.42
7.3.200.0120.00919.39
7.3.190.0030.01916.58
7.3.180.0090.00916.66
7.3.170.0100.00616.44
7.3.160.0110.00516.39
7.3.120.0060.01015.00
7.3.110.0080.00914.98
7.3.100.0120.00114.72
7.3.90.0040.00715.00
7.3.80.0030.00814.93
7.3.70.0050.00615.00
7.3.60.0040.00714.93
7.3.50.0040.00714.94
7.3.40.0090.00614.78
7.3.30.0080.00514.64
7.3.20.0090.00716.74
7.3.10.0060.00616.76
7.3.00.0050.00716.65
7.2.330.0090.01316.55
7.2.320.0070.01016.88
7.2.310.0130.00616.73
7.2.300.0080.00816.43
7.2.290.0110.00616.84
7.2.240.0050.01114.96
7.2.230.0050.00915.20
7.2.220.0030.01514.85
7.2.210.0030.00914.92
7.2.200.0080.00815.08
7.2.190.0030.01015.14
7.2.180.0070.00515.07
7.2.170.0070.01115.17
7.2.160.0040.01115.22
7.2.150.0030.00916.82
7.2.140.0080.00717.02
7.2.130.0500.01016.91
7.2.120.0110.00516.94
7.2.110.0090.00916.79
7.2.100.0070.00616.72
7.2.90.0050.01016.97
7.2.80.0040.00916.91
7.2.70.0040.01117.02
7.2.60.0040.01016.91
7.2.50.0040.00717.05
7.2.40.0040.00816.89
7.2.30.0060.00916.90
7.2.20.0050.00917.00
7.2.10.0080.00416.86
7.2.00.0040.00717.03
7.1.330.0050.01015.95
7.1.320.0090.00515.81
7.1.310.0030.00915.84
7.1.300.0030.00815.92
7.1.290.0070.00415.81
7.1.280.0050.00815.76
7.1.270.0050.00915.94
7.1.260.0020.01015.83
7.1.250.0040.00915.64
7.1.70.0030.00617.27
7.1.60.0060.01619.82
7.1.50.0030.01317.05
7.1.00.0070.07322.45
7.0.200.0030.00716.88
7.0.140.0070.07022.00
7.0.60.0030.08319.90
7.0.50.0170.07017.98
7.0.40.0170.08020.02
7.0.30.0270.08020.12
7.0.20.0930.04720.06
7.0.10.0070.04320.07
7.0.00.0030.09320.07
5.6.280.0130.06321.11
5.6.210.0100.07020.48
5.6.200.0000.04318.20
5.6.190.0030.04320.67
5.6.180.0470.07320.47
5.6.170.0230.06020.54
5.6.160.0200.06720.57
5.6.150.0000.06018.15
5.6.140.0070.06718.13
5.6.130.0030.04718.21
5.6.120.0030.06021.04
5.6.110.0100.07321.00
5.6.100.0070.08320.98
5.6.90.0000.08320.96
5.6.80.0030.07320.52
5.5.350.0370.06320.45
5.5.340.0070.07718.01
5.5.330.0100.04720.21
5.5.320.0030.04020.51
5.5.310.0300.07320.27
5.5.300.0030.04018.10
5.5.290.0100.08317.96
5.5.280.0100.08020.89
5.5.270.0030.05320.97
5.5.260.0030.09020.66
5.5.250.0370.06320.70
5.5.240.0100.07320.17
5.4.450.0670.05719.48
5.4.440.0130.06319.20
5.4.430.0230.06719.39
5.4.420.0100.05719.21
5.4.410.0100.05319.35
5.4.400.0800.00018.74
5.4.390.0870.00018.71
5.4.380.0200.05718.78
5.4.370.0300.05018.50
5.4.360.0270.05718.71
5.4.350.0330.05018.57
5.4.340.0300.05018.79
5.4.320.0050.03712.52
5.4.310.0050.04012.50
5.4.300.0090.04512.52
5.4.290.0070.03712.51
5.4.280.0120.04712.41
5.4.270.0040.03812.41
5.4.260.0070.05318.75
5.4.250.0070.05018.93
5.4.240.0070.05719.00
5.4.230.0130.05018.71
5.4.220.0100.05318.99
5.4.210.0130.04718.82
5.4.200.0270.05018.99
5.4.190.0130.04318.88
5.4.180.0070.05019.03
5.4.170.0030.05718.73
5.4.160.0130.05318.96
5.4.150.0070.05319.02
5.4.140.0100.04716.34
5.4.130.0070.04716.29
5.4.120.0030.05316.30
5.4.110.0070.07316.50
5.4.100.0130.06016.61
5.4.90.0030.06716.61
5.4.80.0170.03716.31
5.4.70.0070.05316.47
5.4.60.0070.05016.61
5.4.50.0170.03716.47
5.4.40.0000.05716.43
5.4.30.0070.05016.46
5.4.20.0100.04316.35
5.4.10.0000.05716.45
5.4.00.0070.04715.94
5.3.290.0070.04212.80
5.3.280.0100.05014.61
5.3.270.0070.05314.70
5.3.260.0070.05014.45
5.3.250.0030.05314.76
5.3.240.0030.06014.63
5.3.230.0100.04714.61
5.3.220.0070.05014.65
5.3.210.0000.06014.75
5.3.200.0070.05314.49
5.3.190.0100.04714.55
5.3.180.0070.05014.48
5.3.170.0030.05714.80
5.3.160.0130.04714.64
5.3.150.0100.04714.80
5.3.140.0100.04714.48
5.3.130.0070.05314.63
5.3.120.0000.06014.53
5.3.110.0100.05014.63
5.3.100.0070.04714.13
5.3.90.0100.05014.19
5.3.80.0070.04713.93
5.3.70.0100.06014.08
5.3.60.0170.06014.00
5.3.50.0030.05313.98
5.3.40.0100.04314.14
5.3.30.0000.05314.00
5.3.20.0070.05013.61
5.3.10.0030.05013.88
5.3.00.0030.05313.82
5.2.170.0030.04311.32
5.2.160.0070.04011.16
5.2.150.0170.05011.23
5.2.140.0070.04011.15
5.2.130.0030.04311.11
5.2.120.0070.03711.12
5.2.110.0070.03710.95
5.2.100.0100.04311.09
5.2.90.0100.03711.34
5.2.80.0130.03311.18
5.2.70.0030.04711.11
5.2.60.0070.04011.14
5.2.50.0130.03711.02
5.2.40.0100.04011.02
5.2.30.0030.04310.89
5.2.20.0030.04310.93
5.2.10.0030.04010.94
5.2.00.0030.04010.81
5.1.60.0100.02710.02
5.1.50.0070.03710.10
5.1.40.0100.02710.23
5.1.30.0100.03010.36
5.1.20.0030.04010.44
5.1.10.0030.03710.08
5.1.00.0070.03010.05
5.0.50.0000.0308.73
5.0.40.0030.0278.50
5.0.30.0030.0408.30
5.0.20.0070.0238.21
5.0.10.0070.0378.28
5.0.00.0030.0408.18
4.4.90.0000.0237.06
4.4.80.0070.0177.06
4.4.70.0030.0277.06
4.4.60.0030.0207.06
4.4.50.0030.0237.06
4.4.40.0000.0377.06
4.4.30.0070.0177.06
4.4.20.0100.0137.06
4.4.10.0000.0237.06
4.4.00.0000.0377.06
4.3.110.0030.0207.06
4.3.100.0100.0137.06
4.3.90.0000.0207.06
4.3.80.0030.0377.06
4.3.70.0000.0307.06
4.3.60.0030.0207.06
4.3.50.0030.0207.06
4.3.40.0070.0277.06
4.3.30.0030.0207.06
4.3.20.0030.0207.06
4.3.10.0000.0237.06
4.3.00.0130.0207.08

preferences:
55.48 ms | 400 KiB | 5 Q