3v4l.org

run code in 300+ PHP versions simultaneously
<?php function new_parse_url($url, $component = -1, $strict = false) { static $map = [ PHP_URL_SCHEME => 'scheme', PHP_URL_USER => 'user', PHP_URL_PASS => 'pass', PHP_URL_HOST => 'host', PHP_URL_PORT => 'port', PHP_URL_PATH => 'path', PHP_URL_QUERY => 'query', PHP_URL_FRAGMENT => 'fragment', ]; static $pattern = <<<REGEXP ! ^ (?P<scheme> [a-z][a-z0-9+.\-]* ) [:] # scheme is mandatory, and followed by a : (?: [/][/] # // indicates that this component is the authority (?: (?P<user> [^:@/]+ ) (?: [:] (?P<pass> [^:@/]+ ) )? [@] )? # auth details are optional (?P<host> [^:/]* ) # host is mandatory. Technically it should be at least 1 char, but PHP has # internal schemes that violate this rule and as much as I dislike it, I # feel that we should pass this (?: [:] (?P<port> [0-9]+ ) )? # port is simply a sequence of decimal digits (?= [/?#]|$ ) # path must be missing or begin with / if authority is present )? (?P<path> [^?#]+ )? # path is everything up to the query/fragment (?: [?] (?P<query> [^#]+ ) )? # query is optional (?: [#] (?P<fragment> .+ ) )? # fragment is optional $ !xi REGEXP; if (!$strict) { return parse_url($url, $component); } if (!preg_match($pattern, $url, $matches)) { return false; } if (isset($map[$component])) { return $matches[$map[$component]]; } $result = []; foreach ($map as $component) { if (isset($matches[$component]) && $matches[$component] !== '') { $result[] = $matches[$component]; } } return $result; } $url = 'http://user:pass@foo.com/test?thing=stuff#fragment'; print_r(new_parse_url($url));

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.0120.00418.30
8.3.50.0160.00521.89
8.3.40.0090.00618.67
8.3.30.0030.01019.17
8.3.20.0040.00420.29
8.3.10.0030.00623.52
8.3.00.0040.00420.84
8.2.180.0120.00316.50
8.2.170.0110.00322.96
8.2.160.0100.00320.47
8.2.150.0170.00324.18
8.2.140.0100.01024.66
8.2.130.0070.00726.16
8.2.120.0080.00021.03
8.2.110.0060.00320.34
8.2.100.0060.00617.91
8.2.90.0060.00318.34
8.2.80.0060.00317.97
8.2.70.0060.00317.49
8.2.60.0030.00717.68
8.2.50.0060.00318.07
8.2.40.0050.00319.95
8.2.30.0060.00318.14
8.2.20.0030.00617.84
8.2.10.0000.00718.19
8.2.00.0050.00317.75
8.1.280.0040.01425.92
8.1.270.0030.00522.07
8.1.260.0120.00326.35
8.1.250.0040.00428.09
8.1.240.0060.00322.14
8.1.230.0120.00020.93
8.1.220.0080.00017.74
8.1.210.0000.00818.97
8.1.200.0040.00417.23
8.1.190.0080.00017.10
8.1.180.0040.00418.10
8.1.170.0040.00418.44
8.1.160.0040.00422.02
8.1.150.0060.00318.59
8.1.140.0040.00417.38
8.1.130.0070.00317.71
8.1.120.0000.00817.38
8.1.110.0040.00417.44
8.1.100.0040.00417.38
8.1.90.0040.00417.48
8.1.80.0070.00017.43
8.1.70.0000.00717.39
8.1.60.0030.00717.58
8.1.50.0000.00817.42
8.1.40.0040.00417.43
8.1.30.0040.00417.68
8.1.20.0060.00317.64
8.1.10.0040.00417.59
8.1.00.0060.00317.42
8.0.300.0000.00719.96
8.0.290.0040.00416.75
8.0.280.0050.00218.50
8.0.270.0040.00417.32
8.0.260.0040.00417.17
8.0.250.0000.00716.93
8.0.240.0000.00717.09
8.0.230.0000.00716.88
8.0.220.0030.00316.84
8.0.210.0040.00416.86
8.0.200.0000.00817.00
8.0.190.0050.00316.98
8.0.180.0000.00716.88
8.0.170.0080.00016.94
8.0.160.0040.00417.00
8.0.150.0070.00016.98
8.0.140.0000.00816.82
8.0.130.0000.00613.43
8.0.120.0000.00816.80
8.0.110.0030.00516.97
8.0.100.0070.00016.83
8.0.90.0040.00416.80
8.0.80.0060.01516.93
8.0.70.0000.00716.88
8.0.60.0040.00416.91
8.0.50.0000.00716.98
8.0.30.0110.00917.15
8.0.20.0060.01217.40
8.0.10.0000.00716.94
8.0.00.0090.01016.84
7.4.330.0050.00015.00
7.4.320.0060.00316.59
7.4.300.0030.00316.37
7.4.290.0070.00016.63
7.4.280.0080.00016.39
7.4.270.0000.00716.43
7.4.260.0080.00016.59
7.4.250.0000.00816.53
7.4.240.0030.00416.56
7.4.230.0000.00716.42
7.4.220.0150.00416.48
7.4.210.0140.00716.56
7.4.200.0040.00416.42
7.4.160.0090.00616.33
7.4.150.0100.00717.40
7.4.140.0070.01017.86
7.4.130.0170.01516.54
7.4.120.0060.01116.62
7.4.110.0070.01116.64
7.4.100.0160.00316.59
7.4.90.0070.01016.47
7.4.80.0110.00719.39
7.4.70.0090.01216.57
7.4.60.0130.00316.43
7.4.50.0050.00316.45
7.4.40.0130.00316.49
7.4.30.0100.00716.50
7.4.00.0070.01115.03
7.3.330.0030.00313.22
7.3.320.0030.00313.25
7.3.310.0040.00416.28
7.3.300.0030.00316.36
7.3.290.0070.01116.44
7.3.280.0130.00716.37
7.3.270.0100.00717.40
7.3.260.0120.00616.38
7.3.250.0050.01216.58
7.3.240.0130.00316.60
7.3.230.0180.00616.39
7.3.210.0100.00716.67
7.3.200.0140.00919.39
7.3.190.0110.00816.63
7.3.180.0040.01216.52
7.3.170.0130.00316.36
7.3.160.0080.00816.64
7.3.120.0140.00414.65
7.2.330.0160.01016.70
7.2.320.0040.01316.29
7.2.310.0130.00316.25
7.2.300.0070.01016.67
7.2.290.0100.00716.42
7.1.70.0080.00017.15
7.1.60.0130.00619.70
7.1.50.0090.00516.96
7.1.00.0000.07722.31
7.0.200.0000.00916.76
7.0.140.0000.07321.97
7.0.100.0300.05020.07
7.0.90.0230.07319.95
7.0.80.0170.07019.89
7.0.70.0330.07019.97
7.0.60.0030.04719.88
7.0.50.0300.06320.27
7.0.40.0100.07320.03
7.0.30.0100.07020.15
7.0.20.0030.06320.14
7.0.10.0100.08020.15
7.0.00.0100.06720.09
5.6.280.0030.07321.02
5.6.250.0030.08720.76
5.6.240.0100.07320.51
5.6.230.0130.06720.50
5.6.220.0130.05320.50
5.6.210.0070.07320.58
5.6.200.0070.08321.05
5.6.190.0030.08321.02
5.6.180.0130.05321.08
5.6.170.0130.06021.04
5.6.160.0130.07721.12
5.6.150.0130.06021.09
5.6.140.0030.06321.01
5.6.130.0130.04321.17
5.6.120.0100.04021.14
5.6.110.0030.05321.03
5.6.100.0100.04021.08
5.6.90.0130.04721.03
5.6.80.0070.04320.41
5.6.70.0030.03320.34
5.6.60.0070.03020.44
5.6.50.0000.04020.43
5.6.40.0000.04320.39
5.6.30.0070.03320.31
5.6.20.0070.05020.37
5.6.10.0030.04020.46
5.6.00.0070.04020.45
5.5.380.0130.07020.50
5.5.370.0030.06720.55
5.5.360.0070.06020.54
5.5.350.0070.07020.41
5.5.340.0100.05320.94
5.5.330.0100.03320.94
5.5.320.0100.03720.63
5.5.310.0170.05020.82
5.5.300.0030.04720.73
5.5.290.0000.04720.77
5.5.280.0130.04020.84
5.5.270.0100.04320.92
5.5.260.0130.03720.73
5.5.250.0130.03320.70
5.5.240.0030.04320.20
5.5.230.0100.03020.20
5.5.220.0000.03720.31
5.5.210.0000.04319.98
5.5.200.0000.04020.09
5.5.190.0000.05320.21
5.5.180.0030.04320.28
5.5.160.0070.03720.24
5.5.150.0000.04720.20
5.5.140.0030.04020.22
5.5.130.0000.04320.13
5.5.120.0070.04320.23
5.5.110.0000.04320.21
5.5.100.0030.04020.08
5.5.90.0100.03020.06
5.5.80.0030.04020.10
5.5.70.0130.07720.09
5.5.60.0130.05720.06
5.5.50.0070.07720.07
5.5.40.0030.08019.94
5.5.30.0070.03319.93
5.5.20.0070.06720.05
5.5.10.0170.05020.13
5.5.00.0100.06320.07
5.4.450.0130.06719.48
5.4.440.0170.03719.45
5.4.430.0000.04319.45
5.4.420.0000.04319.35
5.4.410.0100.03719.18
5.4.400.0000.04319.03
5.4.390.0000.04318.91
5.4.380.0030.03018.95
5.4.370.0000.03319.21
5.4.360.0000.04319.05
5.4.350.0070.02718.95
5.4.340.0070.04018.88
5.4.320.0070.03318.91
5.4.310.0100.03319.04
5.4.300.0130.03019.09
5.4.290.0030.03719.15
5.4.280.0070.03719.12
5.4.270.0100.03719.12
5.4.260.0030.04019.18
5.4.250.0000.04019.04
5.4.240.0000.04019.12
5.4.230.0000.08719.09
5.4.220.0030.03718.90
5.4.210.0000.08018.93
5.4.200.0000.08018.89
5.4.190.0030.04318.89
5.4.180.0070.07318.89
5.4.170.0070.05019.02
5.4.160.0030.07019.12
5.4.150.0100.07719.19
5.4.140.0100.07016.45
5.4.130.0070.07716.41
5.4.120.0100.06716.41
5.4.110.0100.04316.39
5.4.100.0030.07716.36
5.4.90.0130.06316.32
5.4.80.0030.05316.49
5.4.70.0130.05016.38
5.4.60.0030.05016.48
5.4.50.0030.04016.34
5.4.40.0000.04716.45
5.4.30.0070.04016.48
5.4.20.0070.03316.41
5.4.10.0100.06716.45
5.4.00.0030.05315.86
5.3.290.0030.03714.68
5.3.280.0070.07314.63
5.3.270.0070.03714.52
5.3.260.0030.04314.71
5.3.250.0030.08014.72
5.3.240.0070.04714.75
5.3.230.0030.04714.59
5.3.220.0130.05714.50
5.3.210.0000.05014.56
5.3.200.0000.05714.56
5.3.190.0070.07014.52
5.3.180.0100.06014.58
5.3.170.0130.06314.54
5.3.160.0030.08314.71
5.3.150.0030.05314.70
5.3.140.0100.07714.52
5.3.130.0030.08014.50
5.3.120.0030.04714.64
5.3.110.0100.04014.64
5.3.100.0070.05314.02
5.3.90.0070.06714.12
5.3.80.0070.07314.08
5.3.70.0070.04014.13
5.3.60.0130.02713.89
5.3.50.0000.04313.93
5.3.40.0100.06714.05
5.3.30.0030.04714.02
5.3.20.0030.04313.75
5.3.10.0100.06313.75
5.3.00.0070.06713.53
5.2.170.0100.05711.28
5.2.160.0000.04011.20
5.2.150.0070.04011.04
5.2.140.0030.04011.06
5.2.130.0070.04011.16
5.2.120.0000.04311.12
5.2.110.0030.03710.98
5.2.100.0100.03011.14
5.2.90.0000.03710.99
5.2.80.0100.04011.08
5.2.70.0130.04711.21
5.2.60.0070.03711.14
5.2.50.0100.02710.89
5.2.40.0070.05311.04
5.2.30.0030.05310.86
5.2.20.0100.05710.88
5.2.10.0030.04310.93
5.2.00.0000.03310.84
5.1.60.0030.02710.03
5.1.50.0000.0609.99
5.1.40.0070.02710.00
5.1.30.0030.05710.33
5.1.20.0000.04710.41
5.1.10.0000.03310.06
5.1.00.0030.03310.16
5.0.50.0000.0439.11
5.0.40.0100.0309.11
5.0.30.0000.0479.11
5.0.20.0000.0339.11
5.0.10.0030.0209.11
5.0.00.0000.0479.11
4.4.90.0030.0339.11
4.4.80.0070.0309.11
4.4.70.0030.0209.11
4.4.60.0000.0279.11
4.4.50.0030.0209.11
4.4.40.0030.0409.11
4.4.30.0030.0379.11
4.4.20.0000.0179.11
4.4.10.0030.0309.11
4.4.00.0000.0279.11
4.3.110.0030.0279.11
4.3.100.0030.0309.11
4.3.90.0030.0239.11
4.3.80.0000.0279.11
4.3.70.0070.0309.11
4.3.60.0070.0309.11
4.3.50.0000.0309.11
4.3.40.0070.0439.11
4.3.30.0000.0339.11
4.3.20.0000.0279.11
4.3.10.0030.0139.11
4.3.00.0000.0179.11

preferences:
43.15 ms | 401 KiB | 5 Q