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();

preferences:
15.65 ms | 402 KiB | 5 Q