3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xmlns = 'urn:foo'; $dom = new DOMDocument(); /* On the root level the prefix is replaced by default and the namespace for the attribute is lost */ $root = $dom->createElementNS($xmlns, 'element'); $root->setAttributeNS($xmlns, 'foo:attribute', 'bar'); $dom->appendChild($root); /* On the second level the prefix is replaced, the namespace declaration is duplicated and the element gets a prefix that was never provided. */ $child = $dom->createElementNS($xmlns, 'element'); $child->setAttributeNS($xmlns, 'foo:attribute', 'bar'); $root->appendChild($child); /* On the third level the prefix is replaced and the element gets a prefix again. */ $subchild = $dom->createElementNS($xmlns, 'element'); $subchild->setAttributeNS($xmlns, 'foo:attribute', 'bar'); $child->appendChild($subchild); /* If you add the element node before setting the attribute it gets no prefix */ $subchild = $dom->createElementNS($xmlns, 'element'); $child->appendChild($subchild); $subchild->setAttributeNS($xmlns, 'foo:attribute', 'bar'); $dom->formatOutput = TRUE; echo $dom->saveXml(); /* Expected <?xml version="1.0"?> <element xmlns="urn:foo" xmlns:foo="urn:foo" foo:attribute="bar"> <element foo:attribute="bar"> <element foo:attribute="bar"/> </element> </element> */
Output for git.master, git.master_jit, rfc.property-hooks
<?xml version="1.0"?> <element xmlns="urn:foo" xmlns:default="urn:foo" attribute="bar"> <default:element xmlns:default="urn:foo" default:attribute="bar"> <default:element default:attribute="bar"/> <default:element default:attribute="bar"/> </default:element> </element>

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