3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $doc = new DOMDocument(); $doc->loadXML('<products><item>A</item><item>B</item></products>'); $list = $doc->getElementsByTagName('item'); foreach($list as $item) { var_dump(get_class($item)); $itemValue = $item->nodeValue; var_dump(get_class($itemValue)); var_dump(method_exists($itemValue, '__toString')); }
based on uZIqJ
Output for 5.3.0 - 7.2.0
string(10) "DOMElement" Warning: get_class() expects parameter 1 to be object, string given in /in/M45iA on line 12 bool(false) bool(false) string(10) "DOMElement" Warning: get_class() expects parameter 1 to be object, string given in /in/M45iA on line 12 bool(false) bool(false)
Output for 5.0.0 - 5.2.17
string(10) "DOMElement" bool(false) bool(false) string(10) "DOMElement" bool(false) bool(false)
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/M45iA on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: domdocument in /in/M45iA on line 3