3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dom = new DOMDocument(); $dom->loadHtml('<html xmlns:f="foo"><body f:bar="bar"></body></html>'); var_dump((boolean) $dom->getElementsByTagName('head')->length ? '<head> available' : '<head> not available'); var_dump((boolean) $dom->getElementsByTagName('body')->length ? '<body> available' : '<body> not available'); foreach ($dom->getElementsByTagName('body')->item(0)->attributes as $attr) { var_dump($attr->namespaceURI.'#'.$attr->nodeName); }

preferences:
36.26 ms | 402 KiB | 5 Q