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', '...'); 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 8.3.0 - 8.3.4, 8.3.6
<?xml version="1.0"?> <foo xmlns:f="urn:foo" f:foo="..."/> object(DOMNameSpaceNode)#3 (10) { ["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" ["isConnected"]=> bool(true) ["ownerDocument"]=> string(22) "(object value omitted)" ["parentNode"]=> string(22) "(object value omitted)" ["parentElement"]=> string(22) "(object value omitted)" } Fatal error: Uncaught TypeError: DOMElement::removeAttributeNode(): Argument #1 ($attr) must be of type DOMAttr, DOMNameSpaceNode given in /in/jNR9E:14 Stack trace: #0 /in/jNR9E(14): DOMElement->removeAttributeNode(Object(DOMNameSpaceNode)) #1 {main} thrown in /in/jNR9E on line 14
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 <?xml version="1.0"?> <foo xmlns:f="urn:foo" f:foo="..."/> object(DOMNameSpaceNode)#3 (10) { ["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" ["isConnected"]=> bool(true) ["ownerDocument"]=> string(22) "(object value omitted)" ["parentNode"]=> string(22) "(object value omitted)" ["parentElement"]=> string(22) "(object value omitted)" } Fatal error: Uncaught TypeError: DOMElement::removeAttributeNode(): Argument #1 ($attr) must be of type DOMAttr, DOMNameSpaceNode given in /in/jNR9E:14 Stack trace: #0 /in/jNR9E(14): DOMElement->removeAttributeNode(Object(DOMNameSpaceNode)) #1 {main} thrown in /in/jNR9E on line 14
Process exited with code 255.
Output for 8.0.2 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
<?xml version="1.0"?> <foo xmlns:f="urn:foo" f:foo="..."/> 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/jNR9E:14 Stack trace: #0 /in/jNR9E(14): DOMElement->removeAttributeNode(Object(DOMNameSpaceNode)) #1 {main} thrown in /in/jNR9E on line 14
Process exited with code 255.
Output for 8.0.0 - 8.0.1
<?xml version="1.0"?> <foo xmlns:f="urn:foo" f:foo="..."/> 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 ($qualifiedName) must be of type DOMAttr, DOMNameSpaceNode given in /in/jNR9E:14 Stack trace: #0 /in/jNR9E(14): DOMElement->removeAttributeNode(Object(DOMNameSpaceNode)) #1 {main} thrown in /in/jNR9E on line 14
Process exited with code 255.
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
<?xml version="1.0"?> <foo xmlns:f="urn:foo" f:foo="..."/> 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: Argument 1 passed to DOMElement::removeAttributeNode() must be an instance of DOMAttr, instance of DOMNameSpaceNode given in /in/jNR9E:14 Stack trace: #0 /in/jNR9E(14): DOMElement->removeAttributeNode(Object(DOMNameSpaceNode)) #1 {main} thrown in /in/jNR9E on line 14
Process exited with code 255.

preferences:
165.61 ms | 403 KiB | 184 Q