3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $html = <<<HTML <div> <div> <p> ... </p> </div> </div> HTML; $dom = new DOMDocument; $dom->loadHTML($html); $xpath = new DOMXPath($dom); $nodes = $xpath->query('//*'); foreach ($nodes as $node) { printf( "Nodes in List: %d \n" . "Current Tag: %s \n" . "Current Parent: %s \n\n", $nodes->length, $node->tagName, $node->parentNode->tagName ); $node->parentNode->removeChild($node); } echo $dom->saveHtml();
Output for 5.2.6 - 5.6.21, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0RC5
Notice: Undefined property: DOMDocument::$tagName in /in/2qC9I on line 23 Nodes in List: 5 Current Tag: html Current Parent: Nodes in List: 5 Current Tag: body Current Parent: html Nodes in List: 5 Current Tag: div Current Parent: body Nodes in List: 5 Current Tag: div Current Parent: div Nodes in List: 5 Current Tag: p Current Parent: div <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
Output for 5.0.0 - 5.1.1, 5.1.3 - 5.2.5
Notice: Undefined property: DOMDocument::$tagName in /in/2qC9I on line 23 Nodes in List: 5 Current Tag: html Current Parent: Nodes in List: 5 Current Tag: body Current Parent: html Nodes in List: 5 Current Tag: div Current Parent: body Nodes in List: 5 Current Tag: div Current Parent: div Nodes in List: 5 Current Tag: p Current Parent: div <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
Output for 5.1.2
Notice: Undefined property: DOMDocument::$tagName in /in/2qC9I on line 24 Nodes in List: 5 Current Tag: html Current Parent: Nodes in List: 5 Current Tag: body Current Parent: html Nodes in List: 5 Current Tag: div Current Parent: body Nodes in List: 5 Current Tag: div Current Parent: div Nodes in List: 5 Current Tag: p Current Parent: div <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
Output for 4.3.2 - 4.4.1, 4.4.3 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/2qC9I on line 11
Process exited with code 255.
Output for 4.4.2
Fatal error: Cannot instantiate non-existent class: domdocument in /in/2qC9I on line 12
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: domdocument in /in/2qC9I on line 11