3v4l.org

run code in 300+ PHP versions simultaneously
<?php Reproduce code: --------------- $dom = new DOMDocument(); $dom->loadXML( '<foobar><a:foo xmlns:a="urn:a">'. '<b:bar xmlns:b="urn:b"/></a:foo>'. '</foobar>' ); $xpath = new DOMXPath($dom); //get context node and check "a:foo" $context = $dom->documentElement->firstChild; var_dump($context->tagName); // try to override the context node $xpath->registerNamespace('a', 'urn:b'); var_dump( $xpath->evaluate( 'descendant-or-self::a:*', $context )->item(0)->tagName ); // use a prefix not used in context $xpath->registerNamespace('prefix', 'urn:b'); var_dump( $xpath->evaluate( 'descendant-or-self::prefix:*', $context )->item(0)->tagName ); /* Expected result: ---------------- string(5) "a:foo" string(5) "b:bar" string(5) "b:bar" Actual result: ---------------- string(5) "a:foo" string(5) "a:foo" string(5) "b:bar" */
Output for 5.4.0 - 5.4.29
Parse error: syntax error, unexpected 'code' (T_STRING) in /in/sDv0k on line 2
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_STRING in /in/sDv0k on line 2
Process exited with code 255.

preferences:
174.69 ms | 1395 KiB | 66 Q