3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php libxml_use_internal_errors(true); $dom = new DOMDocument; $dom->loadHTML('<h1>junk</h1><div>wth?</div>ANYTHING HERE<div class="col"></div>'); $xpath = new DOMXPath($dom); $found = $xpath->query('//div[@class="col"]/preceding-sibling::text()'); if ($found instanceOf DOMNodeList && $found->length > 0) { $text = $found->item(0); $text->parentNode->removeChild($text); } echo $dom->saveXML($dom->getElementsByTagname('body')->item(0));
Output for 5.1.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
<body><h1>junk</h1><div>wth?</div><div class="col"/></body>
Output for 5.0.0 - 5.0.5
Fatal error: Call to undefined function libxml_use_internal_errors() in /in/6Dq7h on line 2
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING in /in/6Dq7h on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING in /in/6Dq7h on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/6Dq7h on line 8
Process exited with code 255.