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.0120.00818.93
8.3.50.0100.00521.15
8.3.40.0140.00719.04
8.3.30.0030.01420.33
8.3.20.0060.01220.90
8.3.10.0090.00921.19
8.3.00.0080.00023.53
8.2.180.0100.00716.88
8.2.170.0070.00722.96
8.2.160.0140.00020.38
8.2.150.0030.01324.18
8.2.140.0090.00024.66
8.2.130.0160.00326.16
8.2.120.0100.01021.00
8.2.110.0100.00719.39
8.2.100.0110.00017.97
8.2.90.0060.00319.40
8.2.80.0040.00418.03
8.2.70.0000.00917.88
8.2.60.0040.00417.93
8.2.50.0050.00318.07
8.2.40.0030.00517.91
8.2.30.0000.00819.51
8.2.20.0070.00018.01
8.2.10.0070.00017.99
8.2.00.0060.00317.88
8.1.280.0130.00625.92
8.1.270.0120.00323.99
8.1.260.0000.01426.35
8.1.250.0060.01228.09
8.1.240.0110.01122.51
8.1.230.0070.00320.95
8.1.220.0030.00618.77
8.1.210.0050.00520.77
8.1.200.0090.00017.73
8.1.190.0000.00817.66
8.1.180.0000.00818.10
8.1.170.0030.00618.64
8.1.160.0040.00418.88
8.1.150.0000.00718.93
8.1.140.0030.00517.58
8.1.130.0030.00717.81
8.1.120.0040.00417.51
8.1.110.0070.00317.59
8.1.100.0040.00417.57
8.1.90.0050.00317.70
8.1.80.0000.00817.66
8.1.70.0030.00317.61
8.1.60.0030.00617.72
8.1.50.0000.00817.65
8.1.40.0030.00617.73
8.1.30.0030.00617.75
8.1.20.0030.00617.86
8.1.10.0050.00317.63
8.1.00.0030.00617.58
8.0.300.0040.00420.15
8.0.290.0040.00417.18
8.0.280.0000.00718.44
8.0.270.0030.00317.25
8.0.260.0000.00717.13
8.0.250.0000.00717.18
8.0.240.0050.00317.23
8.0.230.0080.00017.22
8.0.220.0050.00217.18
8.0.210.0030.00317.15
8.0.200.0040.00417.08
8.0.190.0000.00717.17
8.0.180.0000.00817.14
8.0.170.0000.00817.16
8.0.160.0040.00417.03
8.0.150.0000.00817.11
8.0.140.0040.00417.11
8.0.130.0040.00413.53
8.0.120.0040.00417.12
8.0.110.0000.00717.03
8.0.100.0000.00717.16
8.0.90.0000.00817.13
8.0.80.0030.01217.21
8.0.70.0000.00816.93
8.0.60.0000.00717.03
8.0.50.0040.00417.09
8.0.30.0140.00517.31
8.0.20.0110.01317.42
8.0.10.0000.00817.08
8.0.00.0090.01117.04
7.4.330.0030.00315.04
7.4.320.0030.00316.77
7.4.300.0030.00316.74
7.4.290.0000.00716.75
7.4.280.0030.00316.73
7.4.270.0030.00316.77
7.4.260.0030.00313.54
7.4.250.0060.00316.73
7.4.240.0040.00416.69
7.4.230.0040.00416.57
7.4.220.0160.00616.80
7.4.210.0090.00716.80
7.4.200.0020.00516.88
7.4.190.0070.00016.82
7.4.160.0100.00616.75
7.4.150.0100.00717.40
7.4.140.0090.01017.86
7.4.130.0100.00716.70
7.4.120.0120.00816.79
7.4.110.0090.01516.87
7.4.100.0130.00616.91
7.4.90.0120.01216.93
7.4.80.0090.00919.39
7.4.70.0060.01016.83
7.4.60.0130.00616.87
7.4.50.0000.00916.68
7.4.40.0030.01022.77
7.4.30.0100.00716.82
7.4.00.0070.00715.07
7.3.330.0000.00513.68
7.3.320.0050.00013.56
7.3.310.0040.00416.65
7.3.300.0030.00316.49
7.3.290.0120.00316.62
7.3.280.0100.00816.62
7.3.270.0030.01417.40
7.3.260.0090.01118.24
7.3.250.0080.01016.73
7.3.240.0110.01116.61
7.3.230.0080.00916.88
7.3.210.0080.00816.81
7.3.200.0140.01019.39
7.3.190.0040.01416.84
7.3.180.0060.00916.52
7.3.170.0100.00716.53
7.3.160.0110.01016.72
7.3.120.0090.00615.00
7.3.10.0150.00016.66
7.3.00.0120.00016.82
7.2.330.0090.00916.89
7.2.320.0220.00017.01
7.2.310.0130.00317.02
7.2.300.0100.01317.04
7.2.290.0170.00016.74
7.2.130.0130.00316.82
7.2.120.0030.00917.14
7.2.110.0060.00617.23
7.2.100.0030.01016.92
7.2.90.0060.00617.08
7.2.80.0130.00316.96
7.2.70.0120.00317.20
7.2.60.0150.00217.29
7.2.50.0030.00917.20
7.2.40.0070.00716.81
7.2.30.0120.00316.98
7.2.20.0060.00617.27
7.2.10.0100.00717.17
7.2.00.0040.00918.32
7.1.250.0060.00915.83
7.1.200.0150.00515.69
7.1.100.0040.00718.46
7.1.70.0030.00517.46
7.1.60.0140.00419.17
7.1.50.0170.01317.18
7.1.00.0030.04322.58
7.0.200.0090.00016.64
7.0.140.0070.07022.06
7.0.80.0070.05019.91
7.0.70.0270.03320.16
7.0.60.0030.03719.99
7.0.50.0070.04020.39
7.0.40.0030.05020.05
7.0.30.0070.04020.08
7.0.20.0070.04020.18
7.0.10.0070.04020.16
7.0.00.0170.04020.14
5.6.280.0030.07021.18
5.6.230.0070.03320.60
5.6.220.0170.07320.52
5.6.210.0030.03720.64
5.6.200.0070.08720.94
5.6.190.0030.04321.02
5.6.180.0200.02320.96
5.6.170.0130.04321.07
5.6.160.0100.04321.13
5.6.150.0030.04321.11
5.6.140.0070.04020.97
5.6.130.0100.03721.10
5.6.120.0030.04320.98
5.6.110.0100.05021.05
5.6.100.0070.03721.04
5.6.90.0030.04721.18
5.6.80.0000.04020.55
5.6.70.0030.04720.39
5.6.60.0030.04020.48
5.6.50.0070.07020.55
5.6.40.0130.07320.41
5.6.30.0000.06720.50
5.6.20.0100.03320.55
5.6.10.0100.06720.40
5.6.00.0030.08020.32
5.5.370.0000.04320.40
5.5.360.0130.07320.38
5.5.350.0100.05320.41
5.5.340.0100.07020.91
5.5.330.0170.07320.93
5.5.320.0030.04720.93
5.5.310.0030.04020.82
5.5.300.0000.06020.75
5.5.290.0000.04720.85
5.5.280.0100.04020.84
5.5.270.0030.04020.79
5.5.260.0030.04320.90
5.5.250.0030.06320.46
5.5.240.0130.03320.25
5.5.230.0070.03720.18
5.5.220.0030.05720.20
5.5.210.0100.03320.32
5.5.200.0030.06020.20
5.5.190.0130.04720.15
5.5.180.0000.07020.27
5.5.160.0070.04020.29
5.5.150.0000.08020.15
5.5.140.0030.05720.24
5.5.130.0170.06720.15
5.5.120.0130.07320.01
5.5.110.0070.07720.23
5.5.100.0100.02720.09
5.5.90.0030.05720.15
5.5.80.0130.07319.95
5.5.70.0100.06720.10
5.5.60.0070.07719.92
5.5.50.0100.07020.08
5.5.40.0070.08020.03
5.5.30.0200.06020.16
5.5.20.0130.07320.08
5.5.10.0070.05320.00
5.5.00.0070.07719.94
5.4.450.0030.03719.43
5.4.440.0100.03719.27
5.4.430.0030.04019.55
5.4.420.0070.04019.22
5.4.410.0070.03319.10
5.4.400.0030.04018.95
5.4.390.0030.03319.03
5.4.380.0100.03719.09
5.4.370.0100.03019.04
5.4.360.0100.06319.04
5.4.350.0070.07319.09
5.4.340.0000.04319.04
5.4.320.0070.08018.95
5.4.310.0100.04719.03
5.4.300.0130.07018.94
5.4.290.0070.03018.94
5.4.280.0000.07019.12
5.4.270.0070.05319.04
5.4.260.0000.04319.03
5.4.250.0130.06318.95
5.4.240.0070.07019.22
5.4.230.0000.06719.15
5.4.220.0030.08319.12
5.4.210.0100.06719.22
5.4.200.0170.06719.04
5.4.190.0030.05718.94
5.4.180.0170.05718.84
5.4.170.0130.07319.15
5.4.160.0100.05718.92
5.4.150.0030.05718.91
5.4.140.0070.06316.49
5.4.130.0170.06316.51
5.4.120.0130.04716.23
5.4.110.0070.07316.54
5.4.100.0130.07016.32
5.4.90.0070.05716.49
5.4.80.0070.07316.31
5.4.70.0100.04316.50
5.4.60.0130.06716.50
5.4.50.0000.04316.46
5.4.40.0070.07316.30
5.4.30.0200.05716.43
5.4.20.0030.06716.46
5.4.10.0000.04716.48
5.4.00.0100.04015.95
5.3.290.0070.08014.68
5.3.280.0100.06014.73
5.3.270.0030.04014.57
5.3.260.0070.07714.59
5.3.250.0100.07014.60
5.3.240.0170.04014.63
5.3.230.0070.04014.73
5.3.220.0130.05314.53
5.3.210.0070.07314.56
5.3.200.0000.05714.60
5.3.190.0030.08014.57
5.3.180.0030.07714.61
5.3.170.0130.07014.56
5.3.160.0030.04714.64
5.3.150.0100.07714.54
5.3.140.0030.05314.64
5.3.130.0170.07014.62
5.3.120.0000.06714.62
5.3.110.0030.07714.55
5.3.100.0100.06714.10
5.3.90.0000.05014.00
5.3.80.0100.04314.16
5.3.70.0070.06714.15
5.3.60.0100.07313.96
5.3.50.0000.08014.09
5.3.40.0070.06713.91
5.3.30.0030.07313.93
5.3.20.0100.06713.85
5.3.10.0000.04013.75
5.3.00.0070.04013.57
5.2.170.0070.05311.89
5.2.160.0100.04711.89
5.2.150.0030.06311.89
5.2.140.0000.06711.89
5.2.130.0100.03311.89
5.2.120.0030.03011.89
5.2.110.0030.03311.89
5.2.100.0000.04711.89
5.2.90.0030.03011.89
5.2.80.0030.06711.89
5.2.70.0000.05011.89
5.2.60.0000.05311.89
5.2.50.0000.06711.89
5.2.40.0100.05711.89
5.2.30.0030.06311.89
5.2.20.0000.04311.89
5.2.10.0030.06311.89
5.2.00.0000.06311.89
5.1.60.0000.05711.89
5.1.50.0030.04011.89
5.1.40.0000.03311.89
5.1.30.0030.05311.89
5.1.20.0070.06011.89
5.1.10.0000.06011.89
5.1.00.0030.05711.89
5.0.50.0030.03011.89
5.0.40.0030.03011.89
5.0.30.0030.03311.89
5.0.20.0030.02011.89
5.0.10.0070.04011.89
5.0.00.0030.03311.89
4.4.90.0030.03011.89
4.4.80.0030.02711.89
4.4.70.0070.02011.89
4.4.60.0000.03711.89
4.4.50.0000.03311.89
4.4.40.0000.03011.89
4.4.30.0000.03711.89
4.4.20.0030.03311.89
4.4.10.0000.03711.89
4.4.00.0070.04711.89
4.3.110.0030.03011.89
4.3.100.0070.02711.89
4.3.90.0000.03011.89
4.3.80.0000.04311.89
4.3.70.0030.01311.89
4.3.60.0130.01011.89
4.3.50.0030.03711.89
4.3.40.0000.04311.89
4.3.30.0000.03311.89
4.3.20.0000.02311.89
4.3.10.0100.02311.89
4.3.00.0070.03011.89

preferences:
67.81 ms | 401 KiB | 5 Q