3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $html = <<<'HTML' <div id='makeme' class='testme'> <span id='whatspanID'>somthing</span> <p class='ptagclass'></p> </div> HTML; $dom = new DOMDocument(); $dom->loadHtml($html); $xpath = new DOMXpath($dom); $div = $xpath->evaluate('//div[@id="makeme"]')->item(0); $nodes = $xpath->evaluate('.//@*', $div); $length = count($nodes); for($i = $length - 1; $i >= 0; --$i) { $node = $nodes->item($i); var_dump($node); $node->parentNode->removeChild($node); } echo $dom->saveHtml($div);
Output for 7.0.0 - 7.1.0
Warning: var_dump(): Not yet implemented in /in/mYH4Y on line 19 object(DOMAttr)#4 (21) { ["name"]=> string(2) "id" ["specified"]=> bool(true) ["value"]=> string(6) "makeme" ["ownerElement"]=> string(22) "(object value omitted)" ["schemaTypeInfo"]=> NULL ["nodeName"]=> string(2) "id" ["nodeValue"]=> string(6) "makeme" ["nodeType"]=> int(2) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> string(22) "(object value omitted)" ["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(2) "id" ["baseURI"]=> NULL ["textContent"]=> string(6) "makeme" } Fatal error: Uncaught DOMException: Not Found Error in /in/mYH4Y:20 Stack trace: #0 /in/mYH4Y(20): DOMNode->removeChild(Object(DOMAttr)) #1 {main} thrown in /in/mYH4Y on line 20
Process exited with code 255.
Output for hhvm-3.12.0
Warning: Not yet implemented object(DOMAttr)#4 (21) { ["nodeName"]=> string(2) "id" ["nodeValue"]=> string(6) "makeme" ["nodeType"]=> int(2) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> string(22) "(object value omitted)" ["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(2) "id" ["baseURI"]=> NULL ["textContent"]=> string(6) "makeme" ["name"]=> string(2) "id" ["specified"]=> bool(true) ["value"]=> string(6) "makeme" ["ownerElement"]=> string(22) "(object value omitted)" ["schemaTypeInfo"]=> NULL } Fatal error: Uncaught exception 'DOMException' with message 'Not Found Error' in /in/mYH4Y:20 Stack trace: #0 /in/mYH4Y(20): DOMNode->removeChild() #1 {main}
Process exited with code 255.
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.3.11 - 5.3.29, 5.4.1 - 5.6.28
Warning: var_dump(): Not yet implemented in /in/mYH4Y on line 19 object(DOMAttr)#4 (21) { ["name"]=> string(2) "id" ["specified"]=> bool(true) ["value"]=> string(6) "makeme" ["ownerElement"]=> string(22) "(object value omitted)" ["schemaTypeInfo"]=> NULL ["nodeName"]=> string(2) "id" ["nodeValue"]=> string(6) "makeme" ["nodeType"]=> int(2) ["parentNode"]=> string(22) "(object value omitted)" ["childNodes"]=> string(22) "(object value omitted)" ["firstChild"]=> string(22) "(object value omitted)" ["lastChild"]=> string(22) "(object value omitted)" ["previousSibling"]=> NULL ["nextSibling"]=> string(22) "(object value omitted)" ["attributes"]=> NULL ["ownerDocument"]=> string(22) "(object value omitted)" ["namespaceURI"]=> NULL ["prefix"]=> string(0) "" ["localName"]=> string(2) "id" ["baseURI"]=> NULL ["textContent"]=> string(6) "makeme" } Fatal error: Uncaught exception 'DOMException' with message 'Not Found Error' in /in/mYH4Y:20 Stack trace: #0 /in/mYH4Y(20): DOMNode->removeChild(Object(DOMAttr)) #1 {main} thrown in /in/mYH4Y on line 20
Process exited with code 255.
Output for 5.3.0 - 5.3.10, 5.4.0
object(DOMAttr)#4 (0) { } Fatal error: Uncaught exception 'DOMException' with message 'Not Found Error' in /in/mYH4Y:20 Stack trace: #0 /in/mYH4Y(20): DOMNode->removeChild(Object(DOMAttr)) #1 {main} thrown in /in/mYH4Y on line 20
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_SL in /in/mYH4Y on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_SL in /in/mYH4Y on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/mYH4Y on line 3
Process exited with code 255.