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->documentElement->appendChild($f); $nodes = $f->getElementsByTagName('*'); echo $nodes->item(0)->tagName . ' -> ' . $nodes->item(0)->nodeValue . '<br/>'; foreach ($nodes as $node) { echo $node->tagName . ' -> ' . $node->nodeValue . '<br/>'; }
based on UhiEj
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Call to a member function appendChild() on null in /in/erYb7:5 Stack trace: #0 {main} thrown in /in/erYb7 on line 5
Process exited with code 255.
Output for 5.6.8 - 5.6.28
Fatal error: Call to a member function appendChild() on null in /in/erYb7 on line 5
Process exited with code 255.
Output for 5.3.19 - 5.5.35
Fatal error: Call to a member function appendChild() on a non-object in /in/erYb7 on line 5
Process exited with code 255.