3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<< HTML <html> <head> <title>A Simple HTML Document</title> </head> <body> <p>This is a very simple HTML document</p> <p>It only has two paragraphs</p> </body> </html> HTML; $dom = new DomDocument; $dom->loadHtml($html); listAllNodes($dom->getElementByTagName('body')); function listAllNodes(DomNode $node) { echo "{$node->nodeName}\n"; foreach ($node->childNodes ?: [] as $node) { listAllNodes($node); } }
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Uncaught Error: Call to undefined method DOMDocument::getElementByTagName() in /in/Tu3F0:18 Stack trace: #0 {main} thrown in /in/Tu3F0 on line 18
Process exited with code 255.

preferences:
184.62 ms | 403 KiB | 180 Q