3v4l.org

run code in 300+ PHP versions simultaneously
<?php $doc = new DOMDocument(); $doc->loadXML( <<<XML <container xmlns="http://symfony.com/schema/dic/services"> CHILDREN </container> XML ); // // Remove xmlns Attribute + Validate it is actually gone. // As you can see, it still remembers a 'xmlns' DOMNameSpaceNode with an empty namespaceURI (which basically is invalid!) // $doc->documentElement->removeAttributeNS('http://symfony.com/schema/dic/services', ''); var_dump($doc->documentElement->getAttributeNode('xmlns')); $namespaces = [...(new DOMXPath($doc))->query('./namespace::*', $doc->documentElement)]; // // Yet when saving the XML : there is no problem, the namespaces are gone. // echo $doc->saveXML(); var_dump($namespaces); // // However ... // When importing the node in a new document, it gets prefixed by <default:container ...> without any xmlns:default declaration // $new = new DOMDocument(); $new->append( $new->importNode($doc->documentElement, true) ); echo $new->saveXML(); // Resulting in invalid XML obviously: $previousErrorReporting = libxml_use_internal_errors(true); libxml_clear_errors(); $parsedAgain = new DOMDocument(); $parsedAgain->loadXML($new->saveXML()); $errors = libxml_get_errors(); libxml_clear_errors(); libxml_use_internal_errors($previousErrorReporting); var_dump($errors);
Output for git.master, git.master_jit, rfc.property-hooks
bool(false) <?xml version="1.0"?> <container> CHILDREN </container> array(1) { [0]=> object(DOMNameSpaceNode)#4 (10) { ["nodeName"]=> string(9) "xmlns:xml" ["nodeValue"]=> string(36) "http://www.w3.org/XML/1998/namespace" ["nodeType"]=> int(18) ["prefix"]=> string(3) "xml" ["localName"]=> string(3) "xml" ["namespaceURI"]=> string(36) "http://www.w3.org/XML/1998/namespace" ["isConnected"]=> bool(true) ["ownerDocument"]=> string(22) "(object value omitted)" ["parentNode"]=> string(22) "(object value omitted)" ["parentElement"]=> string(22) "(object value omitted)" } } <?xml version="1.0"?> <container> CHILDREN </container> array(0) { }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
82.11 ms | 407 KiB | 5 Q