3v4l.org

run code in 300+ PHP versions simultaneously
<?php function load($html) { $document = <<<EOD <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head> <body>!html EOD; // PHP's \DOMDocument::saveXML() encodes carriage returns as &#13; so // normalize all newlines to line feeds. $html = str_replace(["\r\n", "\r"], "\n", $html); // PHP's \DOMDocument serialization adds extra whitespace when the markup // of the wrapping document contains newlines, so ensure we remove all // newlines before injecting the actual HTML body to be processed. $document = strtr($document, ["\n" => '', '!html' => $html]); $dom = new \DOMDocument(); // Ignore warnings during HTML soup loading. @$dom->loadHTML($document, LIBXML_NOBLANKS); return $dom; } function _serialize(\DOMDocument $document) { $body_node = $document->getElementsByTagName('body')->item(0); $html = ''; if ($body_node !== NULL) { foreach ($body_node->childNodes as $node) { $html .= $document->saveXML($node); } } return $html; } print _serialize(load('<a class="sample" href="http://www.example.com/partial/path">foo</a>')); print PHP_EOL; print _serialize(load('<a class="sample" href="http://www.example.com/partial/path'));

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.20.0090.00020.86
8.4.10.0130.00624.08
8.3.140.0080.00419.55
8.3.130.0040.00417.38
8.3.120.0040.00419.21
8.3.110.0120.00020.94
8.3.100.0090.01224.06
8.3.90.0120.00326.77
8.3.80.0050.00518.68
8.3.70.0090.00918.68
8.3.60.0070.01117.13
8.3.50.0100.00617.10
8.3.40.0070.01420.45
8.3.30.0120.00619.27
8.3.20.0040.00424.18
8.3.10.0040.00424.66
8.3.00.0000.00926.16
8.2.260.0120.00316.91
8.2.250.0060.00317.16
8.2.240.0120.00317.37
8.2.230.0090.00022.58
8.2.220.0040.00437.54
8.2.210.0030.00526.77
8.2.200.0030.00616.88
8.2.190.0040.01118.79
8.2.180.0170.00717.38
8.2.170.0060.01219.32
8.2.160.0070.00722.96
8.2.150.0040.00425.66
8.2.140.0040.00424.66
8.2.130.0030.00526.16
8.2.120.0070.00021.03
8.2.110.0040.00419.51
8.2.100.0040.00718.28
8.2.90.0000.00818.41
8.2.80.0050.00318.47
8.2.70.0030.01018.00
8.2.60.0000.00818.00
8.2.50.0130.00519.52
8.2.40.0140.00419.52
8.2.30.0090.00819.52
8.2.20.0110.00619.52
8.2.10.0110.00619.52
8.2.00.0130.00519.52
8.1.310.0120.00616.86
8.1.300.0040.01120.34
8.1.290.0030.00630.84
8.1.280.0110.00825.92
8.1.270.0060.00324.66
8.1.260.0060.00326.35
8.1.250.0040.00428.09
8.1.240.0030.00622.65
8.1.230.0080.00321.16
8.1.220.0030.00517.93
8.1.210.0040.00419.08
8.1.200.0050.00317.48
8.1.190.0050.00317.47
8.1.180.0130.00319.52
8.1.170.0120.00519.52
8.1.160.0150.00119.52
8.1.150.0140.00319.52
8.1.140.0100.00619.52
8.1.130.0120.00419.52
8.1.120.0150.00219.52
8.1.110.0130.00419.52
8.1.100.0130.00319.52
8.1.90.0130.00319.52
8.1.80.0120.00419.52
8.1.70.0120.00519.52
8.1.60.0150.00419.52
8.1.50.0140.00319.52
8.1.40.0130.00519.52
8.1.30.0070.01119.52
8.1.20.0140.00419.52
8.1.10.0110.00719.52
8.1.00.0100.00919.52
8.0.300.0040.00420.14
8.0.290.0000.00717.00
8.0.280.0090.00719.52
8.0.270.0130.00419.52
8.0.260.0160.00219.52
8.0.250.0150.00219.52
8.0.240.0120.00519.52
8.0.230.0120.00419.52
8.0.220.0080.00819.52
8.0.210.0140.00219.52
8.0.200.0100.00619.52
8.0.190.0120.00519.52
8.0.180.0110.00619.52
8.0.170.0140.00419.52
8.0.160.0120.00519.52
8.0.150.0130.00319.52
8.0.140.0120.00519.52
8.0.130.0130.00319.52
8.0.120.0080.00719.52
8.0.110.0140.00119.52
8.0.100.0100.00619.52
8.0.90.0130.00219.52
8.0.80.0160.00219.52
8.0.70.0110.00519.52
8.0.60.0110.00619.52
8.0.50.0120.00319.52
8.0.30.0160.00019.52
8.0.20.0160.00119.52
8.0.10.0120.00419.52

preferences:
55.56 ms | 403 KiB | 5 Q