3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $html = <<<HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> </head> <body> <script type="text/javascript"> var content = '<!DOCTYPE html><html><head></head><body></body></html>' </script> <div id="test">test</div> </body> </html> HTML; $dom = new DOMDocument('1.0', 'UTF-8'); $dom->validateOnParse = true; $dom->loadHTML($html); $xpath = new \DOMXPath($dom); var_dump($xpath->query("descendant-or-self::*[@id = 'test']", $dom));
Output for 5.3.11 - 5.3.29, 5.4.1 - 7.2.0
Warning: DOMDocument::loadHTML(): Unexpected end tag : head in Entity, line: 9 in /in/NPK9P on line 22 Warning: DOMDocument::loadHTML(): Unexpected end tag : script in Entity, line: 10 in /in/NPK9P on line 22 Warning: DOMDocument::loadHTML(): Unexpected end tag : body in Entity, line: 12 in /in/NPK9P on line 22 object(DOMNodeList)#4 (1) { ["length"]=> int(1) }
Output for 5.3.0 - 5.3.10, 5.4.0
Warning: DOMDocument::loadHTML(): Unexpected end tag : head in Entity, line: 9 in /in/NPK9P on line 22 Warning: DOMDocument::loadHTML(): Unexpected end tag : script in Entity, line: 10 in /in/NPK9P on line 22 Warning: DOMDocument::loadHTML(): Unexpected end tag : body in Entity, line: 12 in /in/NPK9P on line 22 object(DOMNodeList)#4 (0) { }
Output for 5.0.0 - 5.1.1, 5.1.3 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NPK9P on line 24 Warning: DOMDocument::loadHTML(): Unexpected end tag : head in Entity, line: 9 in /in/NPK9P on line 22 Warning: DOMDocument::loadHTML(): Unexpected end tag : script in Entity, line: 10 in /in/NPK9P on line 22 Warning: DOMDocument::loadHTML(): Unexpected end tag : body in Entity, line: 12 in /in/NPK9P on line 22 object(DOMNodeList)#4 (0) { }
Output for 5.1.2
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NPK9P on line 25 Warning: DOMDocument::loadHTML(): Unexpected end tag : head in Entity, line: 9 in /in/NPK9P on line 23 Warning: DOMDocument::loadHTML(): Unexpected end tag : script in Entity, line: 10 in /in/NPK9P on line 23 Warning: DOMDocument::loadHTML(): Unexpected end tag : body in Entity, line: 12 in /in/NPK9P on line 23 object(DOMNodeList)#4 (0) { }
Output for 4.3.2 - 4.4.1, 4.4.3 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NPK9P on line 24 Fatal error: Cannot instantiate non-existent class: domdocument in /in/NPK9P on line 19
Process exited with code 255.
Output for 4.4.2
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NPK9P on line 25 Fatal error: Cannot instantiate non-existent class: domdocument in /in/NPK9P on line 20
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/NPK9P on line 24 Fatal error: Cannot instantiate non-existent class: domdocument in /in/NPK9P on line 19