3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<!DOCTYPE html><html><head> <noscript> <style>body { margin: 0; }</style> </noscript> <link href="/style.css" rel="stylesheet"> </head><body></body></html>'; $doc = Dom\HTMLDocument::createFromString($html, LIBXML_NOERROR); echo $doc->saveHTML(), PHP_EOL; $link = $doc->getElementsByTagName('link')->item(0); echo "Link parent: ", $link->parentNode->nodeName, PHP_EOL;
Output for 8.4.9 - 8.4.18, 8.5.2 - 8.5.3
<!DOCTYPE html><html><head> <noscript> <style>body { margin: 0; }</style> <link href="/style.css" rel="stylesheet"> </noscript></head><body></body></html> Link parent: NOSCRIPT
Output for 8.3.5 - 8.3.30
Fatal error: Uncaught Error: Class "Dom\HTMLDocument" not found in /in/TmBjH:10 Stack trace: #0 {main} thrown in /in/TmBjH on line 10
Process exited with code 255.

preferences:
50.48 ms | 479 KiB | 5 Q