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/x'; // hierarchy, DeepController // 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.43
8.3.50.0120.00622.11
8.3.40.0110.00419.02
8.3.30.0080.00619.04
8.3.20.0000.00720.29
8.3.10.0000.00821.96
8.3.00.0040.00422.51
8.2.180.0060.01016.63
8.2.170.0090.00622.96
8.2.160.0070.00720.90
8.2.150.0050.00324.18
8.2.140.0000.00824.66
8.2.130.0030.00526.16
8.2.120.0080.00019.38
8.2.110.0060.00322.25
8.2.100.0090.00319.76
8.2.90.0000.00719.17
8.2.80.0040.00417.97
8.2.70.0030.00617.75
8.2.60.0040.00417.93
8.2.50.0060.00318.07
8.2.40.0060.00318.28
8.2.30.0040.00418.14
8.2.20.0050.00217.74
8.2.10.0000.00717.67
8.2.00.0000.00717.75
8.1.280.0070.01125.92
8.1.270.0030.00522.14
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0040.00423.81
8.1.230.0000.01119.20
8.1.220.0080.00017.74
8.1.210.0080.00018.77
8.1.200.0000.01017.22
8.1.190.0050.00317.53
8.1.180.0000.00818.52
8.1.170.0080.00018.66
8.1.160.0000.00721.95
8.1.150.0080.00018.61
8.1.140.0000.00717.34
8.1.130.0070.00017.71
8.1.120.0030.00317.27
8.1.110.0080.00017.27
8.1.100.0080.00017.36
8.1.90.0040.00417.43
8.1.80.0030.00317.32
8.1.70.0070.00017.40
8.1.60.0030.00617.61
8.1.50.0040.00417.52
8.1.40.0040.00417.52
8.1.30.0060.00317.66
8.1.20.0000.00817.66
8.1.10.0040.00417.52
8.1.00.0040.00417.52
8.0.300.0000.00718.77
8.0.290.0070.00017.16
8.0.280.0000.00718.51
8.0.270.0040.00417.27
8.0.260.0030.00316.89
8.0.250.0000.00716.90
8.0.240.0050.00217.00
8.0.230.0030.00617.04
8.0.220.0000.00717.04
8.0.210.0000.00716.85
8.0.200.0060.00017.04
8.0.190.0040.00417.08
8.0.180.0000.00917.05
8.0.170.0000.00817.00
8.0.160.0000.00716.84
8.0.150.0050.00216.99
8.0.140.0000.00716.84
8.0.130.0000.00513.40
8.0.120.0060.00316.88
8.0.110.0000.00716.87
8.0.100.0040.00416.95
8.0.90.0080.00016.94
8.0.80.0060.01016.86
8.0.70.0040.00416.84
8.0.60.0030.00516.71
8.0.50.0000.00816.74
8.0.30.0170.00317.13
8.0.20.0120.00917.42
8.0.10.0040.00416.95
8.0.00.0110.00716.65
7.4.330.0000.00515.00
7.4.320.0000.00616.44
7.4.300.0000.00616.59
7.4.290.0000.01116.45
7.4.280.0030.00316.45
7.4.270.0070.00016.51
7.4.260.0050.00216.51
7.4.250.0030.00516.38
7.4.240.0020.00616.46
7.4.230.0000.00816.70
7.4.220.0110.00716.53
7.4.210.0090.00716.59
7.4.200.0070.00016.36
7.4.190.0040.00416.68
7.4.160.0150.00816.58
7.4.150.0100.00717.40
7.4.140.0090.01017.86
7.4.130.0030.01316.50
7.4.120.0140.00716.70
7.4.110.0120.00816.64
7.4.100.0090.00816.57
7.4.90.0190.00316.59
7.4.80.0160.00619.39
7.4.70.0130.00316.39
7.4.60.0160.00016.54
7.4.50.0000.00816.36
7.4.40.0070.00522.77
7.4.30.0060.01116.46
7.4.00.0030.01014.75
7.3.330.0000.00513.28
7.3.320.0000.00613.48
7.3.310.0000.00716.32
7.3.300.0030.00316.35
7.3.290.0030.01716.46
7.3.280.0070.00816.49
7.3.270.0070.01017.40
7.3.260.0060.01216.51
7.3.250.0090.01216.57
7.3.240.0100.00616.42
7.3.230.0100.00716.42
7.3.210.0090.00916.38
7.3.200.0100.00719.39
7.3.190.0060.01016.38
7.3.180.0060.01016.54
7.3.170.0080.00816.45
7.3.160.0070.01016.35
7.3.120.0000.01115.07
7.3.10.0040.00916.16
7.3.00.0180.00316.39
7.2.330.0090.00916.71
7.2.320.0090.01216.50
7.2.310.0130.01016.78
7.2.300.0090.00616.40
7.2.290.0030.01316.82
7.2.130.0120.00816.37
7.2.120.0130.01016.60
7.2.110.0220.00016.61
7.2.100.0050.01016.32
7.2.90.0070.01016.31
7.2.80.0130.00816.45
7.2.70.0220.00717.16
7.2.60.0160.00316.55
7.2.50.0170.01016.71
7.2.40.0080.00516.59
7.2.30.0140.00916.52
7.2.20.0050.00716.93
7.2.10.0100.00316.43
7.2.00.0050.00918.07
7.1.250.0030.01315.47
7.1.100.0040.01117.82
7.1.70.0060.00917.01
7.1.60.0130.01019.82
7.1.50.0040.00716.78
7.1.00.0000.08022.45
7.0.200.0000.00716.57
7.0.140.0030.07321.95
7.0.60.0100.05720.02
7.0.50.0100.04717.97
7.0.40.0030.09320.20
7.0.30.0630.06720.08
7.0.20.0200.04320.24
7.0.10.0200.03720.19
7.0.00.0130.06320.03
5.6.280.0070.06320.86
5.6.210.0030.04320.77
5.6.200.0100.07718.28
5.6.190.0070.07720.77
5.6.180.0230.06320.46
5.6.170.0270.08320.59
5.6.160.0100.07320.54
5.6.150.0000.06318.18
5.6.140.0100.06318.21
5.6.130.0070.04018.23
5.6.120.0030.04320.99
5.6.110.0030.09021.04
5.6.100.0170.07721.01
5.6.90.0130.06320.97
5.6.80.0070.06020.39
5.6.70.0230.03020.36
5.5.350.0400.05720.48
5.5.340.0100.07318.09
5.5.330.0070.07320.31
5.5.320.0200.03720.32
5.5.310.0370.05720.37
5.5.300.0030.04717.95
5.5.290.0130.07717.95
5.5.280.0030.09320.66
5.5.270.0030.04020.80
5.5.260.0030.06320.69
5.5.250.0070.05720.63
5.5.240.0100.06020.09
5.4.450.0970.07019.63
5.4.440.0900.06319.61
5.4.430.0400.03719.41
5.4.420.0270.06019.43
5.4.410.0070.06718.70
5.4.400.0830.00018.51
5.4.390.0900.00018.58
5.4.380.0170.06318.84
5.4.370.0300.05718.56
5.4.360.0330.04318.71
5.4.350.0330.04718.80
5.4.340.0400.05718.48
5.4.320.0070.03812.51
5.4.310.0050.04812.51
5.4.300.0070.04512.52
5.4.290.0060.04112.51
5.4.280.0080.03912.41
5.4.270.0090.03312.41
5.4.260.0170.04018.93
5.4.250.0100.05318.75
5.4.240.0070.08018.94
5.4.230.0100.06018.75
5.4.220.0100.06318.73
5.4.210.0130.05318.93
5.4.200.0100.05018.94
5.4.190.0300.05019.07
5.4.180.0170.04718.93
5.4.170.0170.06318.63
5.4.160.0100.05718.81
5.4.150.0100.06318.93
5.4.140.0070.06316.49
5.4.130.0070.04716.32
5.4.120.0100.06316.37
5.4.110.0130.04316.46
5.4.100.0170.05716.43
5.4.90.0170.06016.50
5.4.80.0030.05016.53
5.4.70.0130.04316.48
5.4.60.0070.07316.36
5.4.50.0130.06016.57
5.4.40.0100.04716.45
5.4.30.0100.07016.46
5.4.20.0130.04716.49
5.4.10.0130.07016.44
5.4.00.0030.05715.75
5.3.290.0070.04712.80
5.3.280.0100.07014.64
5.3.270.0070.05714.71
5.3.260.0070.06314.52
5.3.250.0070.05014.70
5.3.240.0070.05014.52
5.3.230.0030.05014.58
5.3.220.0070.07314.59
5.3.210.0070.05314.80
5.3.200.0070.05014.66
5.3.190.0100.05314.58
5.3.180.0070.04714.58
5.3.170.0070.07314.71
5.3.160.0100.05014.56
5.3.150.0030.06014.80
5.3.140.0030.05314.66
5.3.130.0070.06314.47
5.3.120.0030.05714.54
5.3.110.0230.06014.58
5.3.100.0030.05713.95
5.3.90.0200.04014.05
5.3.80.0070.05013.94
5.3.70.0030.05314.13
5.3.60.0130.05314.01
5.3.50.0070.06013.79
5.3.40.0130.04313.88
5.3.30.0070.04713.83
5.3.20.0030.05313.78
5.3.10.0070.04713.84
5.3.00.0030.05013.73
5.2.170.0070.04011.13
5.2.160.0100.05311.38
5.2.150.0000.04311.25
5.2.140.0200.02711.15
5.2.130.0100.04311.03
5.2.120.0070.03711.04
5.2.110.0100.03711.21
5.2.100.0070.03711.14
5.2.90.0000.05310.95
5.2.80.0000.04710.93
5.2.70.0030.05311.19
5.2.60.0000.04311.14
5.2.50.0030.06011.02
5.2.40.0030.04311.10
5.2.30.0000.06311.07
5.2.20.0030.04310.96
5.2.10.0170.02710.96
5.2.00.0100.03710.80
5.1.60.0030.03310.11
5.1.50.0030.03710.01
5.1.40.0000.0409.97
5.1.30.0070.03310.43
5.1.20.0030.03710.45
5.1.10.0030.03710.14
5.1.00.0070.03310.05
5.0.50.0100.0278.58
5.0.40.0030.0378.68
5.0.30.0030.0478.26
5.0.20.0030.0378.21
5.0.10.0030.0278.16
5.0.00.0000.0578.24
4.4.90.0070.0176.84
4.4.80.0000.0236.84
4.4.70.0030.0206.84
4.4.60.0100.0136.84
4.4.50.0030.0206.84
4.4.40.0030.0376.84
4.4.30.0030.0206.84
4.4.20.0030.0206.84
4.4.10.0030.0306.84
4.4.00.0100.0306.84
4.3.110.0000.0276.84
4.3.100.0070.0236.84
4.3.90.0000.0236.84
4.3.80.0000.0436.84
4.3.70.0000.0206.84
4.3.60.0030.0206.84
4.3.50.0070.0176.84
4.3.40.0000.0336.84
4.3.30.0000.0236.84
4.3.20.0070.0136.84
4.3.10.0000.0206.84
4.3.00.0030.0276.78

preferences:
50.03 ms | 401 KiB | 5 Q