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') ); } echo preg_replace('/^<!DOCTYPE.+?>/', '', str_replace( array('<html>', '</html>', '<body>', '</body>'), '', $dom->saveHTML()));
Output for 5.3.3 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
<p>asdasd</p> <img src="thumbnail.php?img=img1.jpg"><p>asdasd</p> <img src="thumbnail.php?img=img2.jpg"><p>asdasd</p> <img src="thumbnail.php?img=img3.jpg"><p>asdasd</p> <img src="thumbnail.php?img=img4.jpg">
Output for 5.0.0 - 5.3.2
<p>asdasd</p> <img src="thumbnail.php?img=img1.jpg"><p>asdasd</p> <img src="thumbnail.php?img=img2.jpg"><p>asdasd</p> <img src="thumbnail.php?img=img3.jpg"><p>asdasd</p> <img src="thumbnail.php?img=img4.jpg">
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/Gv4dp</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/Gv4dp</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/Gv4dp</b> on line <b>17</b><br />