3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pattern = '/(?:src|href)\=(?:\\\'|")([^\\\'"]+)(?:\\\'|")/'; $source = <<<SRC <a href="http://www.sape.ru">some text</a> <img src='logo.jpg' alt=''></a> <img src='../../logo.jpg' alt=''></a> <img src='/path/to/file' alt=''></a> SRC; $baseUrl = 'www.sape.ru'; $callback = function($matches) use ($baseUrl) { $srcTag = $matches[0]; $url = $matches[1]; $search = array( $baseUrl, 'http://' . $baseUrl, 'https://' . $baseUrl, 'http://', 'https://', '../', './', '//', '/' ); $baseUrlReplace = 'http://' . $baseUrl; foreach($search as $s) { $count = 0; $url = preg_replace('/^' . preg_quote($s, '/') . '/', $baseUrlReplace, $url, 1, $count); if ($count == 1) { break; } } var_dump($url); return $url; $url = preg_replace('/^[^\/]\//', '/', $url); $path = parse_url($url, PHP_URL_PATH); //if (empty($path)) { // $path = '/'; //} $query = parse_url($url, PHP_URL_QUERY); if (!empty($query)) { $path.= '?' . $query; } $fragment = parse_url($url, PHP_URL_FRAGMENT); if (!empty($fragment)) { $path.= '#' . $fragment; } $resultUrl = 'http://' . $baseUrl . '/' . ltrim($path, '/'); //var_dump($resultUrl); return str_replace($url, $resultUrl, $srcTag); }; $source = preg_replace_callback($pattern, $callback, $source); var_dump($source);

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.0180.00016.88
8.3.50.0090.01022.09
8.3.40.0110.00419.15
8.3.30.0150.00419.18
8.3.20.0050.00220.18
8.3.10.0160.00023.53
8.3.00.0040.00420.77
8.2.180.0120.00418.63
8.2.170.0060.01222.96
8.2.160.0100.01020.39
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0120.00626.16
8.2.120.0070.00022.39
8.2.110.0030.00620.57
8.2.100.0000.01117.91
8.2.90.0040.00419.17
8.2.80.0080.00417.97
8.2.70.0040.00817.88
8.2.60.0060.00318.05
8.2.50.0050.00318.07
8.2.40.0040.00418.22
8.2.30.0040.00418.19
8.2.20.0070.00017.95
8.2.10.0040.00417.98
8.2.00.0040.00417.92
8.1.280.0040.01425.92
8.1.270.0030.00523.99
8.1.260.0040.01126.35
8.1.250.0000.00728.09
8.1.240.0030.00622.18
8.1.230.0000.01217.54
8.1.220.0050.00317.88
8.1.210.0050.00318.77
8.1.200.0070.00317.60
8.1.190.0000.00817.65
8.1.180.0030.00618.10
8.1.170.0080.00018.75
8.1.160.0000.00822.12
8.1.150.0050.00218.83
8.1.140.0040.00417.69
8.1.130.0070.00017.84
8.1.120.0000.00717.68
8.1.110.0000.00817.58
8.1.100.0000.01017.69
8.1.90.0040.00417.64
8.1.80.0030.00317.66
8.1.70.0030.00617.55
8.1.60.0030.00617.60
8.1.50.0090.00017.59
8.1.40.0040.00417.68
8.1.30.0030.00617.79
8.1.20.0000.00917.84
8.1.10.0060.00317.70
8.1.00.0030.00917.75
8.0.300.0090.00318.77
8.0.290.0000.00717.13
8.0.280.0040.00418.50
8.0.270.0000.00817.32
8.0.260.0000.00716.98
8.0.250.0040.00417.17
8.0.240.0030.00417.12
8.0.230.0030.00517.14
8.0.220.0030.00317.20
8.0.210.0000.00717.16
8.0.200.0030.00317.22
8.0.190.0080.00017.25
8.0.180.0000.00717.17
8.0.170.0030.00517.26
8.0.160.0070.00017.15
8.0.150.0000.00716.97
8.0.140.0040.00416.99
8.0.130.0000.00613.61
8.0.120.0080.00016.99
8.0.110.0000.00717.00
8.0.100.0070.00017.17
8.0.90.0000.00717.02
8.0.80.0030.01217.12
8.0.70.0040.00417.18
8.0.60.0090.00017.16
8.0.50.0040.00417.09
8.0.30.0130.01017.42
8.0.20.0160.00617.40
8.0.10.0000.00717.21
8.0.00.0170.00517.11
7.4.330.0000.00515.14
7.4.320.0030.00316.75
7.4.300.0000.00616.70
7.4.290.0070.00016.84
7.4.280.0000.00716.70
7.4.270.0030.00316.84
7.4.260.0030.00316.88
7.4.250.0050.00216.73
7.4.240.0010.00616.86
7.4.230.0040.00416.67
7.4.220.0160.00016.70
7.4.210.0140.00516.74
7.4.200.0070.00016.92
7.4.190.0000.00716.94
7.4.160.0100.00616.86
7.4.150.0120.00617.40
7.4.140.0090.00917.86
7.4.130.0120.00616.71
7.4.120.0100.01116.68
7.4.110.0070.01016.74
7.4.100.0100.00716.88
7.4.90.0070.01116.80
7.4.80.0100.00719.39
7.4.70.0070.01016.72
7.4.60.0120.00416.87
7.4.50.0050.00016.73
7.4.40.0060.01022.77
7.4.30.0040.01416.86
7.4.00.0050.01215.17
7.3.330.0000.00613.45
7.3.320.0070.00013.32
7.3.310.0050.00216.61
7.3.300.0040.00416.48
7.3.290.0070.01316.52
7.3.280.0050.01216.54
7.3.270.0120.01217.40
7.3.260.0120.01216.68
7.3.250.0090.01016.58
7.3.240.0130.01016.64
7.3.230.0080.00816.66
7.3.210.0180.00016.79
7.3.200.0070.01019.39
7.3.190.0160.00316.80
7.3.180.0000.01716.89
7.3.170.0060.01016.67
7.3.160.0160.00016.57
7.3.120.0040.01415.19
7.3.110.0100.00715.10
7.3.100.0040.01115.11
7.3.90.0000.01415.06
7.3.80.0000.00915.15
7.3.70.0080.00314.83
7.3.60.0030.01415.25
7.3.50.0070.00715.01
7.3.40.0070.01015.13
7.3.30.0070.00714.91
7.3.20.0030.01016.92
7.3.10.0040.01016.89
7.3.00.0030.01216.87
7.2.330.0070.01116.91
7.2.320.0060.01316.92
7.2.310.0120.00916.89
7.2.300.0060.01016.89
7.2.290.0070.01017.02
7.2.250.0040.01515.30
7.2.240.0070.01315.41
7.2.230.0130.00715.19
7.2.220.0040.00715.21
7.2.210.0060.00615.27
7.2.200.0100.00315.47
7.2.190.0030.01315.09
7.2.180.0070.00415.36
7.2.170.0060.00915.32
7.2.130.0070.00717.13
7.2.120.0060.00617.15
7.2.110.0070.00717.15
7.2.100.0070.00717.13
7.2.90.0070.00417.30
7.2.80.0070.00717.24
7.2.70.0060.00616.95
7.2.60.0020.01217.19
7.2.50.0080.00816.99
7.2.40.0070.00617.26
7.2.30.0010.01217.09
7.2.20.0070.00917.03
7.2.10.0090.00716.96
7.2.00.0060.00817.91
7.1.330.0060.00916.26
7.1.320.0090.00015.77
7.1.310.0090.00615.89
7.1.300.0060.00316.20
7.1.290.0030.01315.99
7.1.280.0120.00316.14
7.1.270.0070.00716.02
7.1.260.0090.00616.03
7.1.250.0050.00715.88
7.1.240.0060.00315.55
7.1.230.0160.00316.10
7.1.220.0030.00515.84
7.1.210.0070.00615.93
7.1.200.0060.01015.90
7.1.190.0070.00416.11
7.1.180.0090.00615.99
7.1.170.0070.00415.79
7.1.160.0000.01115.84
7.1.150.0030.00616.00
7.1.140.0030.01115.99
7.1.130.0030.00615.74
7.1.120.0090.00316.00
7.1.110.0030.00715.79
7.1.100.0070.00616.95
7.1.90.0000.00915.99
7.1.80.0030.00715.80
7.1.70.0060.00716.56
7.1.60.0090.01017.66
7.1.50.0090.00916.43
7.1.40.0030.00716.05
7.1.30.0130.00315.75
7.1.20.0030.00616.00
7.1.10.0080.00415.74
7.1.00.0000.04719.18
7.0.330.0000.01215.36
7.0.320.0000.00715.10
7.0.310.0040.00415.69
7.0.300.0140.00015.57
7.0.290.0070.00715.56
7.0.280.0100.00015.27
7.0.270.0030.01015.68
7.0.260.0090.00315.51
7.0.250.0030.00715.40
7.0.240.0000.00915.58
7.0.230.0000.01415.41
7.0.220.0030.00615.49
7.0.210.0030.00615.63
7.0.200.0090.00416.16
7.0.190.0000.01415.41
7.0.180.0040.00415.57
7.0.170.0060.00615.55
7.0.160.0040.00715.54
7.0.150.0030.01015.57
7.0.140.0060.03818.93
7.0.130.0000.00915.58
7.0.120.0080.00315.67
7.0.110.0120.00015.23
7.0.100.0100.02717.79
7.0.90.0100.03817.81
7.0.80.0090.02617.71
7.0.70.0100.02317.78
7.0.60.0070.03017.81
7.0.50.0050.04417.92
7.0.40.0090.02116.87
7.0.30.0030.04516.89
7.0.20.0030.03216.89
7.0.10.0030.02516.90
7.0.00.0060.03616.87
5.6.380.0030.00614.43
5.6.370.0110.00414.79
5.6.360.0050.00814.46
5.6.350.0070.00714.50
5.6.340.0030.00714.57
5.6.330.0080.01114.42
5.6.320.0110.00013.87
5.6.310.0060.00614.42
5.6.300.0030.01014.44
5.6.290.0070.00714.28
5.6.280.0080.03817.90
5.6.270.0040.01114.20
5.6.260.0040.00414.70
5.6.250.0030.02817.56
5.6.240.0060.03717.35
5.6.230.0070.02717.59
5.6.220.0050.02517.40
5.6.210.0060.02717.55
5.6.200.0100.02517.78
5.6.190.0070.02817.68
5.6.180.0070.02517.70
5.6.170.0080.02817.55
5.6.160.0100.02417.90
5.6.150.0050.03717.70
5.6.140.0050.02617.56
5.6.130.0070.02417.72
5.6.120.0070.02517.58
5.6.110.0030.02817.72
5.6.100.0080.04217.77
5.6.90.0030.03517.73
5.6.80.0050.02817.35
5.6.70.0110.03117.39
5.6.60.0060.02217.35
5.6.50.0000.03217.29
5.6.40.0100.02817.21
5.6.30.0120.03017.28
5.6.20.0070.02617.29
5.6.10.0070.03917.37
5.6.00.0070.03117.34
5.5.380.0020.03015.74
5.5.370.0030.02815.68
5.5.360.0020.02815.97
5.5.350.0080.02615.64
5.5.340.0080.02316.04
5.5.330.0080.02516.09
5.5.320.0050.02315.97
5.5.310.0060.02816.04
5.5.300.0090.02215.96
5.5.290.0040.04216.03
5.5.280.0110.02916.04
5.5.270.0050.03316.13
5.5.260.0050.02516.18
5.5.250.0080.02715.81
5.5.240.0070.03315.65
5.5.230.0070.02815.74
5.5.220.0080.03015.76
5.5.210.0080.02715.84
5.5.200.0070.03215.67
5.5.190.0080.04315.76
5.5.180.0040.02915.83
5.5.170.0030.00911.20
5.5.160.0060.03815.70
5.5.150.0020.03515.73
5.5.140.0100.02815.60
5.5.130.0090.03215.84
5.5.120.0100.02515.71
5.5.110.0030.03815.75
5.5.100.0080.01915.47
5.5.90.0080.02315.59
5.5.80.0050.02415.61
5.5.70.0120.03315.67
5.5.60.0030.03915.72
5.5.50.0050.03515.75
5.5.40.0050.02515.64
5.5.30.0050.02715.57
5.5.20.0020.03815.65
5.5.10.0030.02615.67
5.5.00.0080.02315.46
5.4.450.0080.03115.15
5.4.440.0070.02815.18
5.4.430.0050.02615.32
5.4.420.0040.03015.42
5.4.410.0060.02615.18
5.4.400.0070.03915.25
5.4.390.0080.02315.06
5.4.380.0050.03315.09
5.4.370.0030.03314.92
5.4.360.0080.02315.26
5.4.350.0050.03415.09
5.4.340.0050.03815.09
5.4.330.0040.01110.78
5.4.320.0070.03015.15
5.4.310.0070.03414.94
5.4.300.0050.02415.00
5.4.290.0050.03614.94
5.4.280.0030.02915.01
5.4.270.0080.03015.04
5.4.260.0030.04015.10
5.4.250.0080.02615.06
5.4.240.0160.01714.91
5.4.230.0070.01915.13
5.4.220.0080.02015.18
5.4.210.0020.03614.89
5.4.200.0030.03015.06
5.4.190.0060.03014.79
5.4.180.0030.03815.05
5.4.170.0020.03915.19
5.4.160.0110.02814.99
5.4.150.0040.03415.08
5.4.140.0100.03013.77
5.4.130.0070.02213.63
5.4.120.0030.03013.81
5.4.110.0060.02013.61
5.4.100.0060.02813.74
5.4.90.0060.03113.67
5.4.80.0020.03013.75
5.4.70.0070.02813.87
5.4.60.0070.02813.63
5.4.50.0030.02813.71
5.4.40.0030.02713.74
5.4.30.0090.02413.62
5.4.20.0030.02513.84
5.4.10.0020.03613.83
5.4.00.0030.02613.55
5.3.290.0050.03312.64
5.3.280.0030.02412.73
5.3.270.0070.03012.70
5.3.260.0030.03312.53
5.3.250.0060.02912.71
5.3.240.0030.03512.72
5.3.230.0050.03012.63
5.3.220.0080.02812.55
5.3.210.0020.03012.56
5.3.200.0020.02412.59
5.3.190.0030.03212.70
5.3.180.0030.03312.70
5.3.170.0030.03012.66
5.3.160.0050.02812.68
5.3.150.0050.02312.74
5.3.140.0050.03112.65
5.3.130.0000.03112.64
5.3.120.0030.03412.52
5.3.110.0020.03112.55
5.3.100.0080.02012.35
5.3.90.0040.02412.34
5.3.80.0020.02212.39
5.3.70.0030.03712.25
5.3.60.0030.02412.28
5.3.50.0000.02812.10
5.3.40.0070.02312.31
5.3.30.0000.03912.25
5.3.20.0020.02712.22
5.3.10.0080.02012.02
5.3.00.0050.03112.04
5.2.170.0050.02010.07
5.2.160.0040.0179.97
5.2.150.0100.02810.12
5.2.140.0000.02910.05
5.2.130.0010.0189.95
5.2.120.0050.01710.10
5.2.110.0050.02710.12
5.2.100.0090.01710.11
5.2.90.0030.02810.07
5.2.80.0050.02310.08
5.2.70.0000.02210.14
5.2.60.0020.02010.08
5.2.50.0080.01510.12
5.2.40.0030.02510.15
5.2.30.0030.0209.96
5.2.20.0020.0329.99
5.2.10.0040.0279.89
5.2.00.0020.0249.74
5.1.60.0060.0139.13
5.1.50.0060.0139.16
5.1.40.0020.0159.18
5.1.30.0030.0219.28
5.1.20.0040.0199.32
5.1.10.0030.0219.21
5.1.00.0030.0189.11
5.0.50.0010.0198.82
5.0.40.0090.0108.82
5.0.30.0020.0298.82
5.0.20.0080.0138.82
5.0.10.0030.0218.82
5.0.00.0050.0218.82
4.4.90.0030.0128.82
4.4.80.0020.0148.82
4.4.70.0020.0158.82
4.4.60.0010.0138.82
4.4.50.0040.0108.82
4.4.40.0010.0138.82
4.4.30.0020.0108.82
4.4.20.0050.0078.82
4.4.10.0030.0108.82
4.4.00.0030.0178.82
4.3.110.0050.0088.82
4.3.100.0010.0168.82
4.3.90.0060.0148.82
4.3.80.0070.0138.82
4.3.70.0030.0128.82
4.3.60.0030.0108.82
4.3.50.0030.0108.82
4.3.40.0020.0148.82
4.3.30.0000.0158.82
4.3.20.0030.0138.82
4.3.10.0000.0168.82
4.3.00.0020.0178.82

preferences:
45.96 ms | 401 KiB | 5 Q