3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <script> console.log('<h1>aaa<\/h1>'); </script> HTML; $dom = new DOMDocument(); libxml_use_internal_errors(true); $dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8"), LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED); echo $dom->saveHTML();
based on 8c0hD
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.21, 7.4.0 - 7.4.9, 8.0.0alpha1 - beta1
<script> console.log('<h1>aaa<\/h1>'); </script>
Output for 5.1.0 - 5.1.1, 5.1.3 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Notice: Use of undefined constant LIBXML_HTML_NODEFDTD - assumed 'LIBXML_HTML_NODEFDTD' in /in/ldGmr on line 10 Notice: Use of undefined constant LIBXML_HTML_NOIMPLIED - assumed 'LIBXML_HTML_NOIMPLIED' in /in/ldGmr on line 10 Warning: DOMDocument::loadHTML() expects exactly 1 parameter, 2 given in /in/ldGmr on line 10
Output for 5.1.2
Notice: Use of undefined constant LIBXML_HTML_NODEFDTD - assumed 'LIBXML_HTML_NODEFDTD' in /in/ldGmr on line 11 Notice: Use of undefined constant LIBXML_HTML_NOIMPLIED - assumed 'LIBXML_HTML_NOIMPLIED' in /in/ldGmr on line 11 Warning: DOMDocument::loadHTML() expects exactly 1 parameter, 2 given in /in/ldGmr on line 11
Output for 5.0.0 - 5.0.5
Fatal error: Call to undefined function libxml_use_internal_errors() in /in/ldGmr on line 9
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.1, 4.4.3 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/ldGmr on line 8
Process exited with code 255.
Output for 4.4.2
Fatal error: Cannot instantiate non-existent class: domdocument in /in/ldGmr on line 9
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: domdocument in /in/ldGmr on line 8