3v4l.org

run code in 300+ PHP versions simultaneously
<?php function redirect($url = '', array $params = array()) { // スキーム省略に対応 $url = preg_replace_callback( '@^/{2}(?!/)@', function ($matches) { return empty($_SERVER['HTTPS']) || strcasecmp($_SERVER['HTTPS'], 'off') ? 'http://' : 'https://' ; }, $url ); // URLをパースする if (!$p = parse_url($url)) { throw new BadMethodCallException('URLのパースに失敗しました'); } // 相対URLで書かれた場合には絶対URLに補正して再パースさせる if (!isset($p['host'])) { $url = rtrim($GLOBALS['SITE_URL'], '/') . '/' . ltrim($url, '/'); if (!$p = parse_url($url) or !isset($p['host']) or !isset($p['scheme'])) { throw new BadMethodCallException('URLのパースに失敗しました'); } } // クエリ―ストリングをパースして連想配列にする parse_str(isset($p['query']) ? $p['query'] : '', $query); // URLを組み立てていく $user_and_pass[] = isset($p['user']) ? $p['user'] : null; $user_and_pass[] = isset($p['pass']) ? $p['pass'] : null; $host_and_port[] = $p['host']; $host_and_port[] = isset($p['port']) ? $p['port'] : null; $server[] = implode(':', array_filter($user_and_pass, 'is_scalar')); $server[] = implode(':', array_filter($host_and_port, 'is_scalar')); $server_and_path[] = implode('@', array_filter($server, 'strlen')); $server_and_path[] = isset($p['path']) ? ltrim($p['path'], '/') : ''; $sp_and_query[] = implode('/', $server_and_path); $sp_and_query[] = http_build_query($params + $query, '', '&'); $spq_and_fragment[] = implode('?', array_filter($sp_and_query, 'strlen')); $spq_and_fragment[] = isset($p['fragment']) ? $p['fragment'] : null; $scheme_and_spqf[] = $p['scheme']; $scheme_and_spqf[] = implode('#', array_filter($spq_and_fragment, 'is_scalar')); $url = implode('://', $scheme_and_spqf); // 改行コードやNULLバイトを削除する $url = str_replace(array("\r", "\n", "\0"), '', $url); return $url; } $SITE_URL = 'http://user:' . "\n\0\n" . 'pass@exam' . "\n" . 'ple.com:87/p'."\n".'ublic'; var_dump(redirect("\n" . 'test.php?a=b'));

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.0100.00616.63
8.3.50.0070.01122.11
8.3.40.0060.01018.95
8.3.30.0070.00719.21
8.3.20.0000.00720.10
8.3.10.0080.00023.65
8.3.00.0040.00421.02
8.2.180.0110.01116.63
8.2.170.0120.00322.96
8.2.160.0130.00020.47
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0000.00820.97
8.2.110.0000.00921.97
8.2.100.0110.00019.38
8.2.90.0080.00019.35
8.2.80.0050.00317.97
8.2.70.0050.00317.88
8.2.60.0000.01017.80
8.2.50.0070.00318.07
8.2.40.0000.00818.28
8.2.30.0050.00318.29
8.2.20.0080.00018.06
8.2.10.0000.00818.23
8.2.00.0040.00418.11
8.1.280.0070.00725.92
8.1.270.0080.00024.02
8.1.260.0050.00326.35
8.1.250.0060.00328.09
8.1.240.0040.00423.86
8.1.230.0080.00319.22
8.1.220.0080.00017.79
8.1.210.0030.00518.77
8.1.200.0070.00317.38
8.1.190.0050.00517.47
8.1.180.0000.00918.10
8.1.170.0030.00618.89
8.1.160.0030.00521.95
8.1.150.0040.00418.83
8.1.140.0000.00717.64
8.1.130.0030.00317.89
8.1.120.0050.00317.63
8.1.110.0080.00017.54
8.1.100.0040.00417.72
8.1.90.0000.00717.54
8.1.80.0040.00417.55
8.1.70.0000.00717.53
8.1.60.0040.00417.67
8.1.50.0080.00017.62
8.1.40.0030.00617.63
8.1.30.0090.00017.94
8.1.20.0060.00317.89
8.1.10.0050.00317.76
8.1.00.0040.00417.73
8.0.300.0040.00418.77
8.0.290.0050.00317.00
8.0.280.0080.00018.42
8.0.270.0040.00417.32
8.0.260.0030.00317.40
8.0.250.0040.00417.15
8.0.240.0030.00317.09
8.0.230.0080.00017.07
8.0.220.0040.00417.13
8.0.210.0040.00417.19
8.0.200.0000.00617.22
8.0.190.0040.00417.21
8.0.180.0050.00317.19
8.0.170.0060.00317.06
8.0.160.0080.00017.20
8.0.150.0000.00716.97
8.0.140.0000.00917.02
8.0.130.0060.00013.59
8.0.120.0000.00817.01
8.0.110.0000.00817.04
8.0.100.0040.00417.04
8.0.90.0050.00217.01
8.0.80.0170.00317.18
8.0.70.0040.00417.19
8.0.60.0050.00317.13
8.0.50.0000.00817.02
8.0.30.0110.01117.27
8.0.20.0080.01317.42
8.0.10.0000.00817.08
8.0.00.0090.00916.97
7.4.330.0020.00215.15
7.4.320.0000.00616.77
7.4.300.0030.00316.75
7.4.290.0040.00416.86
7.4.280.0070.00016.66
7.4.270.0070.00016.84
7.4.260.0040.00716.84
7.4.250.0050.00316.85
7.4.240.0020.00516.84
7.4.230.0000.00716.92
7.4.220.0150.00416.86
7.4.210.0000.01416.93
7.4.200.0000.00816.86
7.4.160.0100.00616.65
7.4.150.0110.00717.40
7.4.140.0130.00417.86
7.4.130.0080.01016.64
7.4.120.0080.01016.73
7.4.110.0100.00716.91
7.4.100.0120.00816.73
7.4.90.0060.01016.82
7.4.80.0090.00919.39
7.4.70.0120.00916.88
7.4.60.0100.01416.89
7.4.50.0020.00216.44
7.4.40.0060.01016.93
7.4.30.0150.00316.69
7.4.00.0070.00914.97
7.3.330.0050.00013.55
7.3.320.0030.00313.42
7.3.310.0030.00316.57
7.3.300.0030.00316.43
7.3.290.0070.00716.55
7.3.280.0070.00916.52
7.3.270.0030.01317.40
7.3.260.0070.01016.69
7.3.250.0060.01116.59
7.3.240.0070.01116.61
7.3.230.0100.00716.58
7.3.210.0030.01416.78
7.3.200.0110.00619.39
7.3.190.0030.01416.70
7.3.180.0030.01416.65
7.3.170.0040.01216.60
7.3.160.0100.00716.78
7.3.120.0080.00514.92
7.3.110.0070.01114.94
7.3.100.0040.00814.79
7.3.90.0070.00715.20
7.3.80.0100.00715.11
7.3.70.0070.01015.04
7.3.60.0040.01115.14
7.3.50.0100.00315.09
7.3.40.0070.01014.88
7.3.30.0000.01415.15
7.3.20.0030.01216.70
7.3.10.0040.01116.85
7.3.00.0080.00316.61
7.2.330.0160.00616.95
7.2.320.0030.01316.81
7.2.310.0070.01016.96
7.2.300.0030.01416.91
7.2.290.0130.01017.05
7.2.250.0110.00615.34
7.2.240.0140.00715.05
7.2.230.0000.01715.46
7.2.220.0070.00315.12
7.2.210.0000.01615.39
7.2.200.0100.00715.31
7.2.190.0110.00415.37
7.2.180.0070.00715.44
7.2.170.0000.01215.31
7.2.60.0160.00416.85
7.2.00.0060.00619.49
7.1.330.0040.00815.70
7.1.320.0000.01016.00
7.1.310.0030.01016.27
7.1.300.0030.00615.99
7.1.290.0000.01415.86
7.1.280.0090.00615.97
7.1.270.0160.00016.00
7.1.260.0030.01016.04
7.1.200.0100.00315.66
7.1.100.0060.00618.34
7.1.70.0030.00617.43
7.1.60.0120.00619.70
7.1.50.0100.00616.92
7.1.00.0030.07722.55
7.0.200.0060.00316.83
7.0.140.0070.07022.10
7.0.100.0030.07320.03
7.0.90.0070.04019.88
7.0.80.0070.04019.85
7.0.70.0030.04019.85
7.0.60.0000.04720.23
7.0.50.0200.04020.46
7.0.40.0070.04020.24
7.0.30.0030.04320.38
7.0.20.0030.04320.21
7.0.10.0170.06020.38
7.0.00.0000.04720.31
5.6.280.0030.07320.89
5.6.250.0070.04320.55
5.6.240.0070.04020.59
5.6.230.0000.04720.65
5.6.220.0070.03720.45
5.6.210.0100.05720.46
5.6.200.0070.05321.09
5.6.190.0100.05320.94
5.6.180.0100.03720.93
5.6.170.0000.05721.16
5.6.160.0100.04021.04
5.6.150.0070.04021.09
5.6.140.0070.04320.92
5.6.130.0070.04021.12
5.6.120.0130.04721.00
5.6.110.0100.03021.07
5.6.100.0030.03720.91
5.6.90.0030.03720.98
5.6.80.0030.06320.54
5.6.70.0030.06020.33
5.6.60.0100.07720.29
5.6.50.0030.08020.39
5.6.40.0100.06320.51
5.6.30.0100.07720.30
5.6.20.0070.07720.36
5.6.10.0070.05020.40
5.6.00.0030.04720.37
5.5.380.0030.04320.42
5.5.370.0070.04320.52
5.5.360.0000.04720.32
5.5.350.0070.04020.41
5.5.340.0030.04320.79
5.5.330.0100.04320.87
5.5.320.0000.04320.89
5.5.310.0030.04320.90
5.5.300.0070.03720.90
5.5.290.0070.04020.76
5.5.280.0030.04320.91
5.5.270.0030.04320.90
5.5.260.0030.04320.76
5.5.250.0000.03720.57
5.5.240.0130.05020.19
5.5.230.0170.06320.27
5.5.220.0130.07320.20
5.5.210.0100.06320.14
5.5.200.0070.07720.17
5.5.190.0070.06320.11
5.5.180.0070.05020.27
5.5.160.0070.08020.15
5.5.150.0000.08720.10
5.5.140.0030.05720.07
5.5.130.0130.07720.09
5.5.120.0030.04320.23
5.5.110.0070.07719.92
5.5.100.0030.06020.05
5.5.90.0030.08320.08
5.5.80.0030.05320.14
5.5.70.0170.06320.05
5.5.60.0030.05720.06
5.5.50.0100.06719.96
5.5.40.0070.07020.14
5.5.30.0030.08019.91
5.5.20.0030.04320.08
5.5.10.0070.06319.98
5.5.00.0000.06019.96
5.4.450.0100.03319.38
5.4.440.0030.04019.54
5.4.430.0030.03319.18
5.4.420.0000.04319.20
5.4.410.0000.04319.43
5.4.400.0070.07019.10
5.4.390.0030.06019.04
5.4.380.0030.07319.16
5.4.370.0070.07319.21
5.4.360.0070.07719.12
5.4.350.0070.03718.92
5.4.340.0000.05719.14
5.4.320.0070.06719.03
5.4.310.0070.07319.05
5.4.300.0100.07019.02
5.4.290.0130.05019.04
5.4.280.0100.07319.13
5.4.270.0100.07019.13
5.4.260.0130.04718.85
5.4.250.0130.07019.20
5.4.240.0000.08018.85
5.4.230.0030.05718.89
5.4.220.0100.06718.85
5.4.210.0100.06719.04
5.4.200.0030.06018.87
5.4.190.0070.07319.13
5.4.180.0070.08018.84
5.4.170.0100.07318.87
5.4.160.0030.07719.16
5.4.150.0030.06719.05
5.4.140.0030.08016.47
5.4.130.0070.04016.43
5.4.120.0030.05316.42
5.4.110.0070.06716.39
5.4.100.0100.03016.45
5.4.90.0100.06716.56
5.4.80.0070.06716.47
5.4.70.0070.04316.38
5.4.60.0000.04016.40
5.4.50.0100.06316.43
5.4.40.0070.06316.54
5.4.30.0100.03016.36
5.4.20.0030.06016.46
5.4.10.0070.05716.41
5.4.00.0030.08315.59
5.3.290.0070.04714.83
5.3.280.0130.06014.58
5.3.270.0030.03714.56
5.3.260.0070.07714.57
5.3.250.0030.07714.70
5.3.240.0070.06714.73
5.3.230.0130.07014.61
5.3.220.0070.06314.53
5.3.210.0030.05714.66
5.3.200.0070.05014.71
5.3.190.0100.06014.61
5.3.180.0030.06314.57
5.3.170.0000.06014.53
5.3.160.0070.03714.63
5.3.150.0030.03714.73
5.3.140.0030.06014.56
5.3.130.0030.07314.56
5.3.120.0070.04314.57
5.3.110.0000.04314.54
5.3.100.0070.07314.05
5.3.90.0070.06314.03
5.3.80.0100.07714.14
5.3.70.0100.03714.06
5.3.60.0070.06314.17
5.3.50.0000.04314.11
5.3.40.0070.05313.99
5.3.30.0070.06713.95
5.3.20.0030.07313.82
5.3.10.0200.06313.61
5.3.00.0070.04013.68
5.2.170.0100.03711.18
5.2.160.0030.03311.03
5.2.150.0030.05311.07
5.2.140.0100.05311.20
5.2.130.0070.04711.02
5.2.120.0070.02711.17
5.2.110.0030.04011.24
5.2.100.0030.03311.01
5.2.90.0070.04311.11
5.2.80.0030.03011.16
5.2.70.0070.06311.08
5.2.60.0100.05711.11
5.2.50.0030.06010.91
5.2.40.0030.05711.13
5.2.30.0030.05710.84
5.2.20.0000.05711.08
5.2.10.0100.05310.90
5.2.00.0070.04010.59
5.1.60.0000.03310.05
5.1.50.0000.03710.06
5.1.40.0070.04710.06
5.1.30.0130.04310.33
5.1.20.0100.05010.37
5.1.10.0030.05310.07
5.1.00.0000.0509.92
5.0.50.0000.0378.66
5.0.40.0000.0438.50
5.0.30.0070.0678.31
5.0.20.0000.0438.21
5.0.10.0000.0238.18
5.0.00.0000.0438.23
4.4.90.0070.0308.18
4.4.80.0100.0238.18
4.4.70.0030.0178.18
4.4.60.0030.0138.18
4.4.50.0070.0308.18
4.4.40.0030.0378.18
4.4.30.0000.0378.18
4.4.20.0000.0308.18
4.4.10.0070.0208.18
4.4.00.0000.0408.18
4.3.110.0070.0238.18
4.3.100.0030.0338.18
4.3.90.0030.0338.18
4.3.80.0030.0508.18
4.3.70.0000.0278.18
4.3.60.0000.0208.18
4.3.50.0000.0208.18
4.3.40.0000.0378.18
4.3.30.0070.0308.18
4.3.20.0000.0278.18
4.3.10.0030.0278.18
4.3.00.0070.0178.18

preferences:
57.43 ms | 401 KiB | 5 Q