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 = '//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.0140.00418.52
8.3.50.0060.01021.21
8.3.40.0120.00619.13
8.3.30.0110.00320.20
8.3.20.0000.00720.31
8.3.10.0030.00621.96
8.3.00.0050.00322.52
8.2.180.0110.01118.91
8.2.170.0070.01422.96
8.2.160.0120.00422.25
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0040.00421.18
8.2.110.0060.00322.23
8.2.100.0060.00618.03
8.2.90.0040.00419.22
8.2.80.0030.00519.40
8.2.70.0040.00418.00
8.2.60.0040.00417.93
8.2.50.0030.00518.07
8.2.40.0050.00318.15
8.2.30.0040.00419.55
8.2.20.0000.00818.03
8.2.10.0050.00318.04
8.2.00.0000.01018.06
8.1.280.0080.00825.92
8.1.270.0060.00323.99
8.1.260.0110.00726.35
8.1.250.0000.00828.09
8.1.240.0040.00423.96
8.1.230.0060.00619.18
8.1.220.0030.00617.91
8.1.210.0000.00818.77
8.1.200.0030.00717.61
8.1.190.0040.00417.66
8.1.180.0000.00918.10
8.1.170.0040.00418.75
8.1.160.0060.00318.95
8.1.150.0000.00918.83
8.1.140.0040.00417.55
8.1.130.0000.00717.89
8.1.120.0070.00017.64
8.1.110.0040.00417.62
8.1.100.0030.00417.63
8.1.90.0040.00417.57
8.1.80.0000.00717.59
8.1.70.0040.00417.67
8.1.60.0060.00317.77
8.1.50.0040.00417.61
8.1.40.0030.00617.75
8.1.30.0000.00817.85
8.1.20.0030.00517.84
8.1.10.0000.00817.64
8.1.00.0050.00317.59
8.0.300.0030.00518.77
8.0.290.0000.00717.30
8.0.280.0030.00518.57
8.0.270.0070.00017.38
8.0.260.0070.00017.05
8.0.250.0000.00717.15
8.0.240.0040.00417.11
8.0.230.0030.00417.08
8.0.220.0070.00017.15
8.0.210.0030.00517.09
8.0.200.0000.00717.23
8.0.190.0040.00417.12
8.0.180.0040.00417.03
8.0.170.0080.00017.18
8.0.160.0000.00817.13
8.0.150.0030.00517.19
8.0.140.0050.00316.99
8.0.130.0030.00313.61
8.0.120.0090.00017.03
8.0.110.0050.00317.04
8.0.100.0040.00417.03
8.0.90.0070.00017.15
8.0.80.0120.00317.15
8.0.70.0040.00417.14
8.0.60.0040.00416.96
8.0.50.0040.00417.20
8.0.30.0100.00817.23
8.0.20.0110.00817.40
8.0.10.0000.00817.28
8.0.00.0090.01116.89
7.4.330.0000.00516.86
7.4.320.0070.00016.77
7.4.300.0000.00616.66
7.4.290.0000.00716.77
7.4.280.0070.00016.70
7.4.270.0030.00316.81
7.4.260.0030.00313.45
7.4.250.0000.00716.80
7.4.240.0050.00216.77
7.4.230.0000.00716.65
7.4.220.0140.00716.78
7.4.210.0070.00816.84
7.4.200.0040.00416.91
7.4.190.0070.00016.82
7.4.160.0130.00316.77
7.4.150.0130.00317.40
7.4.140.0100.01017.86
7.4.130.0090.01016.77
7.4.120.0110.01016.79
7.4.110.0060.01216.73
7.4.100.0070.01016.82
7.4.90.0140.00316.68
7.4.80.0160.00319.39
7.4.70.0110.00716.75
7.4.60.0070.01116.79
7.4.50.0040.00416.92
7.4.40.0070.01122.77
7.4.30.0090.00916.79
7.4.00.0060.00615.32
7.3.330.0050.00013.48
7.3.320.0000.00513.44
7.3.310.0000.00816.52
7.3.300.0030.00316.48
7.3.290.0030.01016.61
7.3.280.0060.01016.57
7.3.270.0170.00017.40
7.3.260.0100.00716.80
7.3.250.0110.01016.62
7.3.240.0120.00816.84
7.3.230.0050.01416.66
7.3.210.0110.00516.55
7.3.200.0130.00319.39
7.3.190.0100.00716.67
7.3.180.0070.01016.70
7.3.170.0100.00716.71
7.3.160.0030.01216.57
7.3.120.0090.00615.06
7.2.330.0090.00916.93
7.2.320.0120.00616.83
7.2.310.0040.01416.99
7.2.300.0090.00916.89
7.2.290.0130.00416.65
7.2.60.0030.01016.75
7.2.00.0030.01319.63
7.1.200.0140.00015.83
7.1.100.0040.00818.42
7.1.70.0080.00317.29
7.1.60.0040.01819.17
7.1.50.0070.01817.30
7.1.00.0030.03322.32
7.0.200.0040.00416.96
7.0.140.0070.07022.09
7.0.80.0100.06719.89
7.0.70.0170.04319.91
7.0.60.0130.03320.06
7.0.50.0000.04720.38
7.0.40.0030.04319.95
7.0.30.0100.03720.05
7.0.20.0100.03720.14
7.0.10.0070.04019.98
7.0.00.0070.04320.17
5.6.280.0000.07721.09
5.6.230.0030.04720.65
5.6.220.0030.04320.64
5.6.210.0000.05020.70
5.6.200.0100.04320.98
5.6.190.0100.04321.03
5.6.180.0070.03721.20
5.6.170.0070.04021.13
5.6.160.0030.03721.11
5.6.150.0100.07321.09
5.6.140.0070.04021.13
5.6.130.0000.04721.13
5.6.120.0000.03721.10
5.6.110.0030.04020.95
5.6.100.0030.04721.11
5.6.90.0030.04721.18
5.6.80.0030.07020.49
5.6.70.0000.04320.34
5.6.60.0000.04320.41
5.6.50.0030.04020.37
5.6.40.0070.03320.48
5.6.30.0100.03020.34
5.6.20.0030.04320.39
5.6.10.0030.04020.41
5.6.00.0000.05720.45
5.5.370.0000.06020.37
5.5.360.0130.03020.58
5.5.350.0100.03720.41
5.5.340.0000.04320.86
5.5.330.0100.04020.91
5.5.320.0030.03720.65
5.5.310.0070.04020.66
5.5.300.0070.03720.89
5.5.290.0070.04320.67
5.5.280.0030.04720.81
5.5.270.0100.03320.77
5.5.260.0030.04320.93
5.5.250.0070.03720.74
5.5.240.0100.03720.33
5.5.230.0030.04020.29
5.5.220.0000.04320.28
5.5.210.0030.05720.23
5.5.200.0100.04720.30
5.5.190.0070.03720.15
5.5.180.0030.04320.02
5.5.160.0070.03720.30
5.5.150.0030.08320.11
5.5.140.0030.05320.30
5.5.130.0100.03320.29
5.5.120.0030.08020.29
5.5.110.0070.04020.14
5.5.100.0070.08020.10
5.5.90.0070.07320.03
5.5.80.0170.04720.09
5.5.70.0030.08020.16
5.5.60.0070.08020.03
5.5.50.0070.07720.16
5.5.40.0070.03720.17
5.5.30.0030.05020.12
5.5.20.0100.07320.16
5.5.10.0100.03320.00
5.5.00.0030.06320.03
5.4.450.0070.04719.38
5.4.440.0000.04719.20
5.4.430.0030.04019.55
5.4.420.0070.03319.37
5.4.410.0130.04719.39
5.4.400.0030.03719.14
5.4.390.0100.03719.14
5.4.380.0000.04019.14
5.4.370.0030.03719.13
5.4.360.0100.03718.85
5.4.350.0030.04019.09
5.4.340.0100.04019.04
5.4.320.0030.04019.18
5.4.310.0030.06719.18
5.4.300.0130.07018.87
5.4.290.0200.06319.15
5.4.280.0070.07018.84
5.4.270.0070.04019.04
5.4.260.0030.07019.18
5.4.250.0100.07018.90
5.4.240.0130.06718.88
5.4.230.0000.08019.20
5.4.220.0100.07319.09
5.4.210.0070.08019.17
5.4.200.0030.05719.22
5.4.190.0030.06318.89
5.4.180.0070.03719.10
5.4.170.0130.05019.15
5.4.160.0000.06319.16
5.4.150.0130.07019.03
5.4.140.0100.06316.48
5.4.130.0130.06716.46
5.4.120.0070.07316.53
5.4.110.0070.05016.54
5.4.100.0100.07016.48
5.4.90.0070.04016.54
5.4.80.0000.07716.55
5.4.70.0070.05316.52
5.4.60.0030.05316.49
5.4.50.0000.07716.27
5.4.40.0170.06316.37
5.4.30.0030.07716.33
5.4.20.0130.06716.33
5.4.10.0130.07016.43
5.4.00.0100.06715.78
5.3.290.0070.03714.70
5.3.280.0030.07714.57
5.3.270.0070.06314.74
5.3.260.0000.04314.58
5.3.250.0030.07314.70
5.3.240.0070.07314.56
5.3.230.0100.07014.74
5.3.220.0070.06314.66
5.3.210.0070.04714.62
5.3.200.0130.05314.65
5.3.190.0070.07014.56
5.3.180.0170.06314.69
5.3.170.0100.07314.58
5.3.160.0100.06014.60
5.3.150.0000.05314.71
5.3.140.0100.07014.69
5.3.130.0030.04314.61
5.3.120.0100.04714.66
5.3.110.0170.06714.63
5.3.100.0100.07314.16
5.3.90.0030.06014.11
5.3.80.0070.05014.05
5.3.70.0070.06714.16
5.3.60.0030.07714.01
5.3.50.0070.07313.89
5.3.40.0100.06713.91
5.3.30.0130.07013.96
5.3.20.0000.07713.75
5.3.10.0100.06713.79
5.3.00.0070.04713.67
5.2.170.0070.03711.76
5.2.160.0030.05711.76
5.2.150.0100.06311.76
5.2.140.0070.05011.76
5.2.130.0000.06311.76
5.2.120.0070.05711.76
5.2.110.0000.06711.76
5.2.100.0000.04711.76
5.2.90.0070.03311.76
5.2.80.0070.04311.76
5.2.70.0070.05311.76
5.2.60.0030.06011.76
5.2.50.0030.03711.76
5.2.40.0030.03011.76
5.2.30.0030.03011.76
5.2.20.0000.04011.76
5.2.10.0000.04311.76
5.2.00.0100.05711.76
5.1.60.0000.03011.76
5.1.50.0030.05011.76
5.1.40.0070.05011.76
5.1.30.0070.05711.76
5.1.20.0000.05711.76
5.1.10.0000.04011.76
5.1.00.0000.04011.76
5.0.50.0030.04711.76
5.0.40.0000.04011.76
5.0.30.0030.05311.76
5.0.20.0030.02011.76
5.0.10.0030.03311.76
5.0.00.0070.05011.76
4.4.90.0070.02011.76
4.4.80.0070.01711.76
4.4.70.0000.02011.76
4.4.60.0030.03011.76
4.4.50.0030.03011.76
4.4.40.0070.04711.76
4.4.30.0000.04011.76
4.4.20.0000.03711.76
4.4.10.0070.03311.76
4.4.00.0070.05011.76
4.3.110.0000.03711.76
4.3.100.0000.02011.76
4.3.90.0030.02311.76
4.3.80.0070.05011.76
4.3.70.0030.02011.76
4.3.60.0030.03011.76
4.3.50.0030.01711.76
4.3.40.0000.02311.76
4.3.30.0000.03011.76
4.3.20.0000.02311.76
4.3.10.0030.03311.76
4.3.00.0000.04011.76

preferences:
42.19 ms | 400 KiB | 5 Q