3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $html = <<<EOF <p>asdasd</p> <img src="img1.jpg" style="width: 180px;"> <p>asdasd</p> <img src="img2.jpg" style="width: 180px;"> <p>asdasd</p> <img src="img3.jpg" style="width: 180px;"> <p>asdasd</p> <img src="img4.jpg" style="width: 180px;"> EOF; $dom=new DOMDocument(); $dom->loadHTML($html); $imgs = $dom->getElementsByTagName("img"); foreach($imgs as $img){ $img->removeAttribute('style'); $img->setAttribute( 'src' , 'thumbnail.php?img=' . $img->getAttribute('src') ); } $dom->removeChild($dom->firstChild); # remove <html><body></body></html> $dom->replaceChild($dom->firstChild->firstChild->firstChild, $dom->firstChild); echo $dom->saveHTML();
Output for 5.0.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
<p>asdasd</p>
Output for 4.3.2 - 4.4.1, 4.4.3 - 4.4.9
<br /> <b>Fatal error</b>: Cannot instantiate non-existent class: domdocument in <b>/in/Vq5N2</b> on line <b>17</b><br />
Process exited with code 255.
Output for 4.4.2
<br /> <b>Fatal error</b>: Cannot instantiate non-existent class: domdocument in <b>/in/Vq5N2</b> on line <b>18</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<br /> <b>Fatal error</b>: Cannot instantiate non-existent class: domdocument in <b>/in/Vq5N2</b> on line <b>17</b><br />