3v4l.org

run code in 300+ PHP versions simultaneously
<?php $schema = <<<SCHEMA <xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="item"> <xs:complexType> <xs:sequence> <xs:element ref="item" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> <xs:attribute name="is-foo" type="xs:boolean" default="true" use="optional" /> <xs:attribute name="is-bar" type="xs:boolean" default="false" use="optional" /> </xs:complexType> </xs:element> </xs:schema> SCHEMA; $xml = <<<XML <item is-foo="false" is-bar="false"> <item is-bar="true"> <item> <item is-foo="true"> <item /> <item is-foo="true" /> </item> </item> <item is-foo="true" is-bar="true" /> </item> </item> XML; $document = new DOMDocument(); $document->loadXML($xml); $document->schemaValidateSource($schema, LIBXML_SCHEMA_CREATE); $document->resolveExternals = true; $document->substituteEntities = true; $xpath = new DOMXPath($document); foreach ($xpath->query('//item') as $item) { echo $item->getNodePath() . PHP_EOL . ' is-foo : ' . ($item->getAttribute('is-foo') === 'true' ? 'true' : 'false') . PHP_EOL . ' is-bar : ' . ($item->getAttribute('is-bar') === 'true' ? 'true' : 'false') . PHP_EOL; }
Output for git.master_jit, git.master, rfc.property-hooks
/item is-foo : false is-bar : false /item/item is-foo : true is-bar : true /item/item/item[1] is-foo : true is-bar : false /item/item/item[1]/item is-foo : true is-bar : false /item/item/item[1]/item/item[1] is-foo : true is-bar : false /item/item/item[1]/item/item[2] is-foo : true is-bar : false /item/item/item[2] is-foo : true is-bar : true

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:
26.13 ms | 406 KiB | 5 Q