3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $doc = new DOMDocument(); $f = $doc->createDocumentFragment(); $f->appendXML('<h1>Foo</h1><h2>Bar</h2><p>lorem ipsum</p>'); $doc->importNode($f); $nodes->getElementsByTagName('*'); echo $nodes->item(0)->tagName . ' -> ' . $nodes->item(0)->nodeValue . '<br/>'; foreach ($nodes as $node) { echo $node->tagName . ' -> ' . $node->nodeValue . '<br/>'; }
based on 3Y6K4
Output for 7.0.5 - 7.2.0
Notice: Undefined variable: nodes in /in/k5hCf on line 6 Fatal error: Uncaught Error: Call to a member function getElementsByTagName() on null in /in/k5hCf:6 Stack trace: #0 {main} thrown in /in/k5hCf on line 6
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Notice: Undefined variable: nodes in /in/k5hCf on line 6 Fatal error: Uncaught Error: Call to a member function getElementsByTagName() on unknown in /in/k5hCf:6 Stack trace: #0 {main} thrown in /in/k5hCf on line 6
Process exited with code 255.
Output for 5.6.8 - 5.6.28
Notice: Undefined variable: nodes in /in/k5hCf on line 6 Fatal error: Call to a member function getElementsByTagName() on null in /in/k5hCf on line 6
Process exited with code 255.
Output for 5.3.19 - 5.5.35
Notice: Undefined variable: nodes in /in/k5hCf on line 6 Fatal error: Call to a member function getElementsByTagName() on a non-object in /in/k5hCf on line 6
Process exited with code 255.