3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<'HTML' <body>bar bar HTML; echo "Strict Error Checking: FALSE\n"; echo str_repeat("-", 50),"\n"; try { $document = new DOMDocument(); $document->strictErrorChecking = FALSE; $document->loadXML($html); } catch (Throwable $e) { echo "Catched: ", get_class($e), "\n"; } echo str_repeat("-", 50),"\n"; echo "Strict Error Checking: TRUE\n"; echo str_repeat("-", 50),"\n"; try { $document = new DOMDocument(); $document->strictErrorChecking = TRUE; $document->loadXML($html); } catch (Throwable $e) { echo "Catched: ", get_class($e), "\n"; } echo str_repeat("-", 50),"\n"; libxml_use_internal_errors(TRUE); echo "Strict Error Checking: FALSE\n"; echo str_repeat("-", 50),"\n"; try { $document = new DOMDocument(); $document->strictErrorChecking = FALSE; $document->loadHTML($html); } catch (Throwable $e) { echo "Catched: ", get_class($e), "\n"; } echo str_repeat("-", 50),"\n"; echo "Strict Error Checking: TRUE\n"; echo str_repeat("-", 50),"\n"; try { $document = new DOMDocument(); $document->strictErrorChecking = TRUE; $document->loadHTML($html); } catch (Throwable $e) { echo "Catched: ", get_class($e), "\n"; } echo str_repeat("-", 50),"\n"; $document = new DOMDocument(); $document->appendChild($document->createElement('foo')); $document->appendChild($document->createElement('foo')); echo $document->saveXML(); $document = new DOMDocument(); $document->strictErrorChecking = TRUE; $document->appendChild($document->createElement('foo')); $document->appendChild($document->createElement('foo')); echo $document->saveXML();
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Strict Error Checking: FALSE -------------------------------------------------- Warning: DOMDocument::loadXML(): Premature end of data in tag body line 1 in Entity, line: 1 in /in/ssj4L on line 12 -------------------------------------------------- Strict Error Checking: TRUE -------------------------------------------------- Warning: DOMDocument::loadXML(): Premature end of data in tag body line 1 in Entity, line: 1 in /in/ssj4L on line 24 -------------------------------------------------- Strict Error Checking: FALSE -------------------------------------------------- -------------------------------------------------- Strict Error Checking: TRUE -------------------------------------------------- -------------------------------------------------- <?xml version="1.0"?> <foo/> <foo/> <?xml version="1.0"?> <foo/> <foo/>
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Strict Error Checking: FALSE -------------------------------------------------- Warning: DOMDocument::loadXML(): Premature end of data in tag body line 1 in Entity, line: 1 in /in/ssj4L on line 12 -------------------------------------------------- Strict Error Checking: TRUE -------------------------------------------------- Warning: DOMDocument::loadXML(): Premature end of data in tag body line 1 in Entity, line: 1 in /in/ssj4L on line 24 -------------------------------------------------- Strict Error Checking: FALSE -------------------------------------------------- -------------------------------------------------- Strict Error Checking: TRUE -------------------------------------------------- -------------------------------------------------- <?xml version="1.0"?> <foo/> <foo/> <?xml version="1.0"?> <foo/> <foo/>

preferences:
164.68 ms | 403 KiB | 154 Q