3v4l.org

run code in 300+ PHP versions simultaneously
<?php $doc = new DOMDocument(); $doc->loadXML('<html><example a="b">Test</example></html>'); $example = $doc->getElementsByTagName('example')->item(0); $attr = $example->getAttributeNode('a'); var_dump($attr->name); print_r($attr);
Output for 8.3.0 - 8.3.7
string(1) "a" DOMAttr Object ( [specified] => 1 [schemaTypeInfo] => [name] => a [value] => b [ownerElement] => (object value omitted) [nodeName] => a [nodeValue] => b [nodeType] => 2 [parentNode] => (object value omitted) [parentElement] => (object value omitted) [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [nextSibling] => [attributes] => [isConnected] => 1 [ownerDocument] => (object value omitted) [namespaceURI] => [prefix] => [localName] => a [baseURI] => / [textContent] => b )
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
string(1) "a" DOMAttr Object ( [specified] => 1 [schemaTypeInfo] => [name] => a [value] => b [ownerElement] => (object value omitted) [nodeName] => a [nodeValue] => b [nodeType] => 2 [parentNode] => (object value omitted) [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [nextSibling] => [attributes] => [ownerDocument] => (object value omitted) [namespaceURI] => [prefix] => [localName] => a [baseURI] => / [textContent] => b )
Output for 7.0.20, 7.1.5 - 7.1.33, 7.2.6 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
string(1) "a" DOMAttr Object ( [name] => a [specified] => 1 [value] => b [ownerElement] => (object value omitted) [schemaTypeInfo] => [nodeName] => a [nodeValue] => b [nodeType] => 2 [parentNode] => (object value omitted) [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [nextSibling] => [attributes] => [ownerDocument] => (object value omitted) [namespaceURI] => [prefix] => [localName] => a [baseURI] => / [textContent] => b )
Output for 7.1.0
string(1) "a" Warning: print_r(): Not yet implemented in /in/Nojr6 on line 10 DOMAttr Object ( [name] => a [specified] => 1 [value] => b [ownerElement] => (object value omitted) [schemaTypeInfo] => [nodeName] => a [nodeValue] => b [nodeType] => 2 [parentNode] => (object value omitted) [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [attributes] => [ownerDocument] => (object value omitted) [namespaceURI] => [prefix] => [localName] => a [baseURI] => / [textContent] => b )
Output for 5.3.11 - 5.3.29, 5.4.1 - 5.4.45, 5.5.0 - 5.5.36, 5.6.0 - 5.6.28, 7.0.0 - 7.0.14
string(1) "a" DOMAttr Object Warning: print_r(): Not yet implemented in /in/Nojr6 on line 10 ( [name] => a [specified] => 1 [value] => b [ownerElement] => (object value omitted) [schemaTypeInfo] => [nodeName] => a [nodeValue] => b [nodeType] => 2 [parentNode] => (object value omitted) [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [attributes] => [ownerDocument] => (object value omitted) [namespaceURI] => [prefix] => [localName] => a [baseURI] => / [textContent] => b )
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.10, 5.4.0
string(1) "a" DOMAttr Object ( )
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/Nojr6 on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/Nojr6 on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/Nojr6 on line 6
Process exited with code 255.

preferences:
223.79 ms | 401 KiB | 377 Q