3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dom = new \DOMDocument(); $elt = $dom ->appendChild($dom->createElementNS('some:namespace', 'foo')) ->appendChild($dom->createElement('bar')); $xml = $dom->saveXML(); var_dump($elt->namespaceURI); $dom = new \DOMDocument(); $dom->loadXml($xml); $elt = $dom->documentElement->firstChild; var_dump($elt->namespaceURI);
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.26, 8.0.0 - 8.0.13, 8.1rc1 - rc3
NULL string(14) "some:namespace"

preferences:
37.13 ms | 459 KiB | 5 Q