3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html_string = " <div> Below are object Node with the html code </div> <script> alert('i want this to be replaced. it has no newline'); </script> <div> I don't want this to be replaced </div> <script> console.log('i also want this to be replaced. It has newline'); </script> <div> This is a div tag and not a script, so it should not be replaced </div> <script> console.warn(Finally, this should be replaced, it also has newline'); </script> <div> The above is the final result of the replacements </div> "; $doc = new DOMDocument(); $doc->loadHTML("<html>$html_string</html>", LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXPath($doc); foreach ($xpath->query('//script') as $script) { $comment = $doc->createComment('THIS SCRIPT CONTENT HERE HAS BEEN ALTERED'); $script->parentNode->replaceChild($comment, $script); } echo substr($doc->saveHTML(), 6, -8);

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.4.130.0130.00818.01
8.4.120.0150.00521.00
8.4.110.0040.00520.92
8.4.100.0110.01017.96
8.4.90.0120.00921.03
8.4.80.0100.01121.21
8.4.70.0130.00719.25
8.4.60.0110.00920.95
8.4.50.0110.00922.60
8.4.40.0090.00917.98
8.4.30.0090.00920.83
8.4.20.0120.00921.05
8.4.10.0160.00318.02
8.3.260.0100.00617.12
8.3.250.0120.00719.54
8.3.240.0090.00916.98
8.3.230.0110.00817.11
8.3.220.0120.00819.63
8.3.210.0060.00616.90
8.3.200.0030.00616.71
8.3.190.0030.00817.32
8.3.180.0100.00619.35
8.3.170.0110.00717.64
8.3.160.0090.00919.25
8.3.150.0150.00417.52
8.3.140.0100.01017.36
8.3.130.0120.00318.80
8.3.120.0080.00019.33
8.3.110.0090.00620.94
8.3.100.0070.00324.06
8.3.90.0130.00326.77
8.3.80.0100.00016.88
8.3.70.0150.00017.00
8.3.60.0070.01018.68
8.3.50.0100.00517.65
8.3.40.0110.00719.02
8.3.30.0070.00718.95
8.3.20.0050.00321.14
8.3.10.0030.00722.33
8.3.00.0080.00021.09
8.2.290.0110.00916.98
8.2.280.0090.01118.59
8.2.270.0160.00317.38
8.2.260.0110.00617.33
8.2.250.0040.00417.92
8.2.240.0000.00917.52
8.2.230.0090.00022.58
8.2.220.0090.00937.54
8.2.210.0150.00326.77
8.2.200.0000.00917.25
8.2.190.0190.00016.98
8.2.180.0060.01218.49
8.2.170.0140.00322.96
8.2.160.0070.00720.89
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0030.00618.53
8.2.120.0050.00326.35
8.2.110.0070.00321.35
8.2.100.0120.00018.28
8.2.90.0030.00618.22
8.2.80.0040.00418.43
8.2.70.0060.00318.43
8.2.60.0040.00418.59
8.2.50.0000.00918.10
8.2.40.0000.00819.80
8.2.30.0000.00719.72
8.2.20.0040.00418.38
8.2.10.0060.00619.78
8.2.00.0060.00318.75
8.1.330.0100.00416.94
8.1.320.0130.00816.34
8.1.310.0070.00417.07
8.1.300.0080.00018.41
8.1.290.0090.00030.84
8.1.280.0070.00725.92
8.1.270.0060.00320.78
8.1.260.0000.00826.35
8.1.250.0000.00828.09
8.1.240.0060.00322.96
8.1.230.0040.00721.46
8.1.220.0050.00318.27
8.1.210.0000.01019.23
8.1.200.0030.00617.85
8.1.190.0030.00617.73
8.1.180.0040.00418.10
8.1.170.0040.00418.80
8.1.160.0040.00419.41
8.1.150.0050.00319.23
8.1.140.0040.00419.34
8.1.130.0000.00720.59
8.1.120.0070.00017.84
8.1.110.0060.00317.94
8.1.100.0090.00017.80
8.1.90.0070.00017.85
8.1.80.0090.00017.93
8.1.70.0000.00717.82
8.1.60.0030.00618.06
8.1.50.0040.00417.86
8.1.40.0030.00517.96
8.1.30.0040.00418.09
8.1.20.0040.00418.14
8.1.10.0000.00818.03
8.1.00.0090.00017.82
8.0.300.0040.00421.89
8.0.290.0030.00617.00
8.0.280.0040.00418.87
8.0.270.0050.00217.17
8.0.260.0030.00318.88
8.0.250.0030.00617.25
8.0.240.0000.00717.39
8.0.230.0030.00517.35
8.0.220.0040.00417.32
8.0.210.0000.00717.21
8.0.200.0000.00717.26
8.0.190.0000.00817.39
8.0.180.0000.00717.27
8.0.170.0030.00617.29
8.0.160.0000.00917.36
8.0.150.0050.00317.24
8.0.140.0040.00417.15
8.0.130.0030.00313.78
8.0.120.0040.00417.21
8.0.110.0040.00417.14
8.0.100.0000.00717.33
8.0.90.0050.00317.34
8.0.80.0070.01117.38
8.0.70.0060.00317.33
8.0.60.0000.00717.06
8.0.50.0040.00417.22
8.0.30.0070.01517.33
8.0.20.0060.01217.32
8.0.10.0040.00417.50
8.0.00.0080.01117.04
7.4.330.0000.00517.15
7.4.320.0030.00317.02
7.4.300.0030.00316.91
7.4.290.0030.00317.04
7.4.280.0030.00516.96
7.4.270.0030.00316.97
7.4.260.0080.00016.84
7.4.250.0030.00316.73
7.4.240.0000.00716.85
7.4.230.0050.00217.09
7.4.220.0080.00016.73
7.4.210.0060.01117.08
7.4.200.0040.00416.66
7.4.160.0100.00716.85
7.4.130.0160.00716.67
7.4.120.0030.02116.88
7.4.110.0090.00917.00
7.4.100.0100.00717.08
7.4.90.0060.01316.93
7.4.80.0030.01619.39
7.4.70.0000.01816.77
7.4.60.0030.01416.80
7.4.50.0060.00316.86
7.4.40.0090.00917.10
7.4.00.0070.01015.07
7.3.330.0030.00313.51
7.3.320.0050.00013.46
7.3.310.0000.00716.68
7.3.300.0040.00416.67
7.3.290.0000.00816.54
7.3.280.0080.00816.59
7.3.260.0090.01116.98
7.3.240.0090.00816.75
7.3.230.0030.01316.84
7.3.210.0130.00616.84
7.3.200.0030.01316.61
7.3.190.0100.00716.73
7.3.180.0140.00316.77
7.3.170.0040.01316.72
7.3.160.0100.01316.77
7.3.40.0060.01014.92
7.3.30.0080.00414.92
7.3.20.0090.00616.69
7.3.10.0090.00616.81
7.3.00.0100.00316.80
7.2.330.0060.01116.79
7.2.320.0070.01117.18
7.2.310.0030.01316.78
7.2.300.0080.00817.00
7.2.290.0110.00917.06
7.2.170.0130.01315.19
7.2.160.0030.01715.00
7.2.150.0040.01917.05
7.2.140.0050.00617.06
7.2.130.0100.00016.83
7.2.120.0060.01016.84
7.2.110.0150.00317.01
7.2.100.0070.00717.02
7.2.90.0060.01516.95
7.2.80.0070.01117.11
7.2.70.0030.01016.93
7.2.60.0040.00717.10
7.2.50.0160.00317.02
7.2.40.0180.00316.78
7.2.30.0110.01116.91
7.2.20.0110.00917.04
7.2.10.0060.00617.00
7.2.00.0100.00017.14
7.1.280.0000.01215.90
7.1.270.0120.00815.93
7.1.260.0000.01215.87
7.1.250.0040.00815.72

preferences:
30.26 ms | 403 KiB | 5 Q