3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $dom = '<a href="costam"><img src="ddd"></a>'; $doc = new DOMDocument; $doc->loadHTML($dom); $href = $doc->getElementsByTagName('a')->item(0); $href->setAttribute("target", "_blank"); echo $doc->saveHTML($href);
based on ojI3Q
Output for 5.5.0 - 5.6.15, 5.6.17 - 5.6.38, hhvm-3.12.14, hhvm-3.15.4 - 3.22.0, 7.0.1 - 7.2.11
<a href="costam" target="_blank"><img src="ddd"></a>
Output for 5.6.16, hhvm-3.13.2, 7.0.0

Process exited with code 137.