3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $xml = "<root> <parent> <child name='Child1' /> <child name='Child2' /> <subparent> <child name='Child3' /> </subparent> </parent> <child name='Child4' /> </root>"; $dom=new DOMDocument(); $dom->loadXML($xml); $val=$dom->getElementsByTagName('root')->item(0); print_r($val); var_dump($val-nodeValue);
based on vjcUf
Output for 7.2.0
DOMElement Object ( [tagName] => root [schemaTypeInfo] => [nodeName] => root [nodeValue] => [nodeType] => 1 [parentNode] => (object value omitted) [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [nextSibling] => [attributes] => (object value omitted) [ownerDocument] => (object value omitted) [namespaceURI] => [prefix] => [localName] => root [baseURI] => / [textContent] => ) Warning: Use of undefined constant nodeValue - assumed 'nodeValue' (this will throw an Error in a future version of PHP) in /in/DdJVG on line 17 Notice: Object of class DOMElement could not be converted to int in /in/DdJVG on line 17 Warning: A non-numeric value encountered in /in/DdJVG on line 17 int(1)
Output for 7.1.5 - 7.1.10
DOMElement Object ( [tagName] => root [schemaTypeInfo] => [nodeName] => root [nodeValue] => [nodeType] => 1 [parentNode] => (object value omitted) [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [nextSibling] => [attributes] => (object value omitted) [ownerDocument] => (object value omitted) [namespaceURI] => [prefix] => [localName] => root [baseURI] => / [textContent] => ) Notice: Use of undefined constant nodeValue - assumed 'nodeValue' in /in/DdJVG on line 17 Notice: Object of class DOMElement could not be converted to int in /in/DdJVG on line 17 Warning: A non-numeric value encountered in /in/DdJVG on line 17 int(1)
Output for 7.1.0
DOMElement Object ( [tagName] => root [schemaTypeInfo] => [nodeName] => root [nodeValue] => [nodeType] => 1 [parentNode] => (object value omitted) [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [attributes] => (object value omitted) [ownerDocument] => (object value omitted) [namespaceURI] => [prefix] => [localName] => root [baseURI] => / [textContent] => ) Notice: Use of undefined constant nodeValue - assumed 'nodeValue' in /in/DdJVG on line 17 Notice: Object of class DOMElement could not be converted to int in /in/DdJVG on line 17 Warning: A non-numeric value encountered in /in/DdJVG on line 17 int(1)
Output for 7.0.20
DOMElement Object ( [tagName] => root [schemaTypeInfo] => [nodeName] => root [nodeValue] => [nodeType] => 1 [parentNode] => (object value omitted) [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [nextSibling] => [attributes] => (object value omitted) [ownerDocument] => (object value omitted) [namespaceURI] => [prefix] => [localName] => root [baseURI] => / [textContent] => ) Notice: Use of undefined constant nodeValue - assumed 'nodeValue' in /in/DdJVG on line 17 Notice: Object of class DOMElement could not be converted to int in /in/DdJVG on line 17 int(1)
Output for 5.3.19 - 7.0.7
DOMElement Object ( [tagName] => root [schemaTypeInfo] => [nodeName] => root [nodeValue] => [nodeType] => 1 [parentNode] => (object value omitted) [childNodes] => (object value omitted) [firstChild] => (object value omitted) [lastChild] => (object value omitted) [previousSibling] => [attributes] => (object value omitted) [ownerDocument] => (object value omitted) [namespaceURI] => [prefix] => [localName] => root [baseURI] => / [textContent] => ) Notice: Use of undefined constant nodeValue - assumed 'nodeValue' in /in/DdJVG on line 17 Notice: Object of class DOMElement could not be converted to int in /in/DdJVG on line 17 int(1)