3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class NewDomElement extends DOMElement { function foo () { foreach ($this->childNodes as $childNode) {} } } $dom = new DomDocument; $dom->registerNodeClass('DOMElement', 'NewDomElement'); $dom->loadHtml('<div><span/>text</div>'); // this is important !!! text node after element node $node = $dom->getElementsByTagName('div')->item(0); $node->foo(); $node->nodeValue = ''; $frag = $node->ownerDocument->createDocumentFragment(); echo get_class($frag); // Expected DOMDocumentFragment instead of NewDomElement $node = $dom->getElementsByTagName('div')->item(0); $node->foo(); $node->nodeValue = ''; $frag = $node->ownerDocument->createDocumentFragment(); echo get_class($frag); // Expected DOMDocumentFragment instead of NewDomElement $node = $dom->getElementsByTagName('div')->item(0); $node->foo(); $node->nodeValue = ''; $frag = $node->ownerDocument->createDocumentFragment(); echo get_class($frag); // Expected DOMDocumentFragment instead of NewDomElement
based on iBELi