3v4l.org

run code in 300+ PHP versions simultaneously
<?php $homepage = "https://example.com/"; $html = '<img class="drt" src="100.png"><img src="../101.png"><img src="/102.png"><img src="103.png">'; $dom = new DOMDocument(); $dom->loadHTML($html); foreach ($dom->getElementsByTagName('img') as $img) { $src = $img->getAttribute('src'); $src = $homepage.basename($src); $img->setAttribute('src', $src); } // hacky way! remove unwanted doctype ect $ret = preg_replace('~<(?:!DOCTYPE|/?(?:html|body|head))[^>]*>\s*~i', '', $dom->saveHTML()); echo trim(str_replace('<meta http-equiv="Content-Type" content="text/html;charset=utf-8">', '', $ret)); // proper way! but you dont have correct DOM, no <body> // remove <!DOCTYPE //$dom->removeChild($dom->doctype); // remove <html><body></body></html> //$dom->replaceChild($dom->firstChild->firstChild->firstChild, $dom->firstChild); // //echo $dom->saveHTML();

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.5.10.0090.00917.10
8.5.00.0100.01120.64
8.4.150.0010.00214.05
8.4.140.0060.00317.85
8.4.130.0150.00618.94
8.4.120.0110.00824.16
8.4.110.0130.00719.32
8.4.100.0130.00919.28
8.4.90.0080.01220.54
8.4.80.0040.00620.92
8.4.70.0100.00918.52
8.4.60.0140.00918.94
8.4.50.0140.00718.88
8.4.40.0090.00617.99
8.4.30.0040.01220.96
8.4.20.0110.00424.34
8.4.10.0090.00019.61
8.3.280.0100.01018.76
8.3.270.0110.01017.09
8.3.260.0110.00916.92
8.3.250.0130.00719.35
8.3.240.0150.00517.32
8.3.230.0130.00816.93
8.3.220.0100.00919.34
8.3.210.0120.00618.81
8.3.200.0040.00417.01
8.3.190.0100.01117.09
8.3.180.0120.00617.23
8.3.170.0100.01019.10
8.3.160.0040.00418.89
8.3.150.0120.00617.15
8.3.140.0050.00519.01
8.3.130.0100.01017.21
8.3.120.0100.00019.49
8.3.110.0030.00719.01
8.3.100.0000.00918.91
8.3.90.0090.00016.88
8.3.80.0030.00619.36
8.3.70.0110.00716.88
8.3.60.0070.01416.88
8.3.50.0060.01423.78
8.3.40.0130.00720.69
8.3.30.0150.00419.13
8.3.20.0080.00024.18
8.3.10.0060.00324.66
8.3.00.0080.00026.16
8.2.290.0090.01120.57
8.2.280.0110.00720.47
8.2.270.0070.01119.09
8.2.260.0060.00318.60
8.2.250.0100.00618.65
8.2.240.0060.00319.12
8.2.230.0000.00920.94
8.2.220.0000.00824.06
8.2.210.0170.00326.77
8.2.200.0090.00617.00
8.2.190.0120.00618.91
8.2.180.0030.01625.92
8.2.170.0140.00719.12
8.2.160.0080.00522.96
8.2.150.0000.00825.66
8.2.140.0030.00524.66
8.2.130.0040.00426.16
8.2.120.0080.00026.35
8.2.110.0100.00019.47
8.2.100.0060.00619.95
8.2.90.0060.00318.33
8.2.80.0000.00818.29
8.2.70.0080.00018.16
8.2.60.0050.00520.32
8.2.50.0030.00518.07
8.2.40.0050.00318.41
8.2.30.0000.00819.56
8.2.20.0040.00418.25
8.2.10.0000.00719.66
8.2.00.0000.00719.63
8.1.330.0090.00922.04
8.1.320.0120.00816.50
8.1.310.0090.00918.66
8.1.300.0060.00320.30
8.1.290.0040.00418.88
8.1.280.0070.01425.92
8.1.270.0050.00324.07
8.1.260.0080.00028.09
8.1.250.0040.00428.09
8.1.240.0030.00622.76
8.1.230.0060.00620.99
8.1.220.0080.00018.03
8.1.210.0050.00320.88
8.1.200.0030.00617.85
8.1.190.0040.00417.73
8.1.180.0050.00318.86
8.1.170.0030.00617.97
8.1.160.0040.00419.21
8.1.150.0000.00719.07
8.1.140.0080.00019.07
8.1.130.0040.00420.46
8.1.120.0000.00717.79
8.1.110.0030.00517.92
8.1.100.0040.00417.86
8.1.90.0040.00417.74
8.1.80.0080.00017.91
8.1.70.0030.00317.80
8.1.60.0040.00417.92
8.1.50.0040.00417.86
8.1.40.0040.00417.86
8.1.30.0030.00518.04
8.1.20.0050.00318.07
8.1.10.0050.00317.90
8.1.00.0060.00317.84
8.0.300.0000.00719.93
8.0.290.0030.00517.13
8.0.280.0070.00018.79
8.0.270.0040.00417.13
8.0.260.0070.00018.76
8.0.250.0030.00317.27
8.0.240.0000.00617.36
8.0.230.0070.00017.25
8.0.220.0030.00317.30
8.0.210.0040.00417.24
8.0.200.0040.00417.32
8.0.190.0000.00717.34
8.0.180.0030.00617.32
8.0.170.0050.00317.30
8.0.160.0030.00517.27
8.0.150.0030.00617.23
8.0.140.0040.00417.17
8.0.130.0040.00413.70
8.0.120.0000.00717.27
8.0.110.0040.00417.37
8.0.100.0040.00417.37
8.0.90.0040.00417.41
8.0.80.0080.01317.34
8.0.70.0040.00417.34
8.0.60.0000.00717.27
8.0.50.0000.00817.20
8.0.30.0100.00717.63
8.0.20.0140.00517.59
8.0.10.0050.00317.22
8.0.00.0030.02017.01
7.4.330.0070.00015.55
7.4.320.0070.00016.92
7.4.300.0040.00417.04
7.4.290.0000.00717.05
7.4.280.0040.00416.97
7.4.270.0040.00416.89
7.4.260.0050.00013.73
7.4.250.0050.00316.85
7.4.240.0000.00816.92
7.4.230.0070.00017.02
7.4.220.0030.00517.13
7.4.210.0130.00617.18
7.4.200.0000.00717.13
7.4.130.0090.00916.90
7.4.120.0150.00416.78
7.4.110.0070.01016.68
7.4.100.0060.01016.83
7.4.90.0140.00316.61
7.4.80.0180.00016.93
7.4.70.0110.00916.73
7.4.60.0130.00317.11
7.4.50.0120.00417.04
7.4.40.0120.00616.81
7.4.30.0030.01316.84
7.4.20.0100.00617.05
7.4.10.0060.01017.11
7.4.00.0090.00917.02
7.3.330.0040.00416.68
7.3.320.0030.00313.55
7.3.310.0070.00016.68
7.3.300.0000.00716.63
7.3.290.0090.00916.63
7.3.280.0040.01116.65
7.3.260.0130.00316.79
7.3.230.0090.01016.80
7.3.220.0080.00816.60
7.3.210.0100.00716.66
7.3.200.0100.00617.07
7.3.190.0030.01416.90
7.3.180.0050.01117.05
7.3.170.0110.00616.88
7.3.160.0030.01316.80
7.3.150.0130.00316.96
7.3.140.0090.00616.62
7.3.130.0100.00716.64
7.3.120.0070.01817.07
7.3.110.0060.01116.96
7.3.100.0160.00016.77
7.3.90.0110.00716.93
7.3.80.0090.00916.80
7.3.70.0060.01216.84
7.3.60.0130.01016.82
7.3.50.0070.01016.72
7.3.40.0060.01216.80
7.3.30.0130.00716.72
7.3.20.0120.00916.80
7.3.10.0070.01116.80
7.3.00.0040.02016.73
7.2.330.0120.00616.98
7.2.320.0130.00317.06
7.2.310.0100.00717.11
7.2.300.0090.00917.07
7.2.290.0100.00617.15
7.2.280.0060.01017.14
7.2.270.0100.00617.08
7.2.260.0100.00916.98
7.2.250.0070.01117.05
7.2.240.0090.00916.94
7.2.230.0060.01317.06
7.2.220.0090.00916.97
7.2.210.0110.00717.04
7.2.200.0150.00417.12
7.2.190.0140.00317.18
7.2.180.0060.01116.90
7.2.170.0000.01917.04
7.2.160.0100.01317.02
7.2.150.0090.00917.15
7.2.140.0000.01817.20
7.2.130.0110.00917.16
7.2.120.0110.00717.00
7.2.110.0120.01317.07
7.2.100.0190.00716.95
7.2.90.0120.01217.13
7.2.80.0120.01217.02
7.2.70.0410.01417.12
7.2.60.0120.00617.07
7.2.50.0040.01517.01
7.2.40.0160.00916.95
7.2.30.0100.01317.19
7.2.20.0060.01217.11
7.2.10.0290.00316.96
7.2.00.0150.01117.02

preferences:
41.4 ms | 403 KiB | 5 Q