3v4l.org

run code in 300+ PHP versions simultaneously
<?php $document = new DOMDocument(); $document->appendChild($document->createElement('foo')); // add attribute in namespace $document->documentElement->setAttributeNS('urn:foo', 'f:foo', 'bar'); echo $document->saveXML(); // fetch the namespace definition node $namespace = $document->documentElement->getAttributeNodeNS('http://www.w3.org/2000/xmlns/', 'f'); var_dump($namespace); // it should be an attribute node but isn't $document->documentElement->removeAttributeNode($namespace);
Output for git.master, git.master_jit, rfc.property-hooks
<?xml version="1.0"?> <foo xmlns:f="urn:foo" f:foo="bar"/> object(DOMNameSpaceNode)#3 (8) { ["nodeName"]=> string(7) "xmlns:f" ["nodeValue"]=> string(7) "urn:foo" ["nodeType"]=> int(18) ["prefix"]=> string(1) "f" ["localName"]=> string(1) "f" ["namespaceURI"]=> string(7) "urn:foo" ["ownerDocument"]=> string(22) "(object value omitted)" ["parentNode"]=> string(22) "(object value omitted)" } Fatal error: Uncaught TypeError: DOMElement::removeAttributeNode(): Argument #1 ($attr) must be of type DOMAttr, DOMNameSpaceNode given in /in/jkC5s:14 Stack trace: #0 /in/jkC5s(14): DOMElement->removeAttributeNode(Object(DOMNameSpaceNode)) #1 {main} thrown in /in/jkC5s on line 14
Process exited with code 255.

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:
61.69 ms | 402 KiB | 8 Q