3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Html { public static 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</body> </html> EOD; // 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); return $dom; } /** * Converts the body of a \DOMDocument back to an HTML snippet. * * The function serializes the body part of a \DOMDocument back to an (X)HTML * snippet. The resulting (X)HTML snippet will be properly formatted to be * compatible with HTML user agents. * * @param \DOMDocument $document * A \DOMDocument object to serialize, only the tags below the first <body> * node will be converted. * * @return string * A valid (X)HTML snippet, as a string. */ public static 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; } } $source = <<<EOT <table> <tr> <td>L</td> <td>R</td> </tr> </table> EOT; $document = Html::load($source); $out['document'] = "\n" . $document->saveHTML(); $body = $document->getElementsByTagName('body')->item(0); $out['body'] = "\n" . $document->saveXML($body); $table = $body->childNodes[0]; $out['table'] = "\n" . $document->saveXML($table); $out['serialize'] = "\n" . Html::serialize($document); var_export($out);

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.70.0170.00016.75
8.3.60.0120.00316.75
8.3.50.0110.00416.56
8.3.40.0120.00319.14
8.3.30.0070.00718.98
8.3.20.0000.00824.18
8.3.10.0080.00024.66
8.3.00.0030.00526.16
8.2.180.0110.00725.92
8.2.170.0090.00919.21
8.2.160.0070.01422.96
8.2.150.0040.00425.66
8.2.140.0080.00024.66
8.2.130.0000.00826.16
8.2.120.0040.00426.35
8.2.110.0090.00020.90
8.2.100.0100.00318.28
8.2.90.0080.00018.25
8.2.80.0080.00019.15
8.2.70.0090.00017.88
8.2.60.0030.00618.28
8.2.50.0080.00018.05
8.2.40.0060.00318.27
8.2.30.0000.00818.49
8.2.20.0000.00818.45
8.2.10.0080.00219.63
8.2.00.0040.00419.70
8.1.280.0110.00425.92
8.1.270.0080.00023.99
8.1.260.0030.00728.09
8.1.250.0080.00028.09
8.1.240.0030.00724.04
8.1.230.0040.00719.97
8.1.220.0040.00418.27
8.1.210.0000.00818.77
8.1.200.0030.00617.50
8.1.190.0050.00517.60
8.1.180.0030.00618.10
8.1.170.0110.00018.82
8.1.160.0030.00519.12
8.1.150.0040.00419.11
8.1.140.0030.00619.14
8.1.130.0030.00320.39
8.1.120.0070.00017.78
8.1.110.0030.00617.76
8.1.100.0000.00717.70
8.1.90.0030.00517.85
8.1.80.0040.00417.77
8.1.70.0040.00417.70
8.1.60.0030.00617.83
8.1.50.0030.00517.82
8.1.40.0040.00417.82
8.1.30.0040.00417.98
8.1.20.0000.00817.89
8.1.10.0080.00017.89
8.1.00.0040.00417.75
8.0.300.0000.00718.77
8.0.290.0030.00517.00
8.0.280.0000.00818.63
8.0.270.0040.00418.48
8.0.260.0000.00718.83
8.0.250.0000.00717.30
8.0.240.0070.00017.31
8.0.230.0040.00417.20
8.0.220.0030.00317.25
8.0.210.0040.00417.29
8.0.200.0040.00417.33
8.0.190.0000.00717.35
8.0.180.0030.00617.28
8.0.170.0040.00417.28
8.0.160.0070.00017.20
8.0.150.0030.00517.25
8.0.140.0040.00817.15
8.0.130.0030.00313.68
8.0.120.0060.00317.21
8.0.110.0040.00417.26
8.0.100.0040.00417.29
8.0.90.0000.00717.17
8.0.80.0090.00617.13
8.0.70.0040.00417.35
8.0.60.0000.00717.34
8.0.50.0050.00317.29
8.0.30.0120.01017.31
8.0.20.0120.00917.17
8.0.10.0070.01017.46
8.0.00.0040.01117.45
7.4.330.0050.00015.55
7.4.320.0050.00216.87
7.4.300.0040.00416.84
7.4.290.0040.00416.71
7.4.280.0060.00316.91
7.4.270.0050.00316.80
7.4.260.0050.00013.50
7.4.250.0030.00516.79
7.4.240.0020.00516.88
7.4.230.0030.00316.75
7.4.220.0050.00216.77
7.4.210.0070.01016.91
7.4.200.0040.00416.70
7.4.160.0060.01416.78
7.4.150.0160.00616.80
7.4.140.0110.00816.89
7.4.130.0030.01316.71
7.4.120.0150.00016.97
7.4.110.0080.00716.71
7.4.100.0040.01116.63
7.4.90.0070.00816.93
7.4.80.0140.00716.71
7.4.70.0060.00916.91
7.4.60.0060.00916.88
7.4.50.0050.01016.80
7.4.40.0070.00716.74
7.4.30.0090.00916.80
7.4.20.0000.01716.75
7.4.10.0030.01116.57
7.4.00.0030.01516.69
7.3.330.0070.00016.70
7.3.320.0030.00313.69
7.3.310.0040.00416.75
7.3.300.0000.00616.71
7.3.290.0120.00716.72
7.3.270.0100.01016.67
7.3.260.0130.00516.71
7.3.250.0000.01316.84
7.3.240.0000.01816.83
7.3.230.0090.00916.68
7.3.220.0000.01416.64
7.3.210.0100.00716.63
7.3.200.0070.00716.67
7.3.190.0060.00916.69
7.3.180.0060.01116.71
7.3.170.0110.00716.53
7.3.160.0060.00916.72
7.3.150.0060.01116.62
7.3.140.0070.01016.61
7.3.130.0030.01416.61
7.3.120.0090.00616.72
7.3.110.0060.01116.58
7.3.100.0060.00916.59
7.3.90.0090.00916.87
7.3.80.0110.00816.76
7.3.70.0090.00816.73
7.3.60.0030.01316.69
7.3.50.0060.00916.71
7.3.40.0110.00416.70
7.3.30.0070.01116.65
7.3.20.0100.00916.75
7.3.10.0030.01416.78
7.3.00.0060.00916.73

preferences:
58.32 ms | 400 KiB | 5 Q