3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $html = "<link rel='stylesheet' href='http://www.foo.com/bar/baz.min.css' type='text/css' id='23434' foo='bar' media='all'/>"; $dom = new DOMDocument(); $dom->loadHTML($html); $link = $dom->getElementById('23434'); $link->setAttribute('foo', 'test'); echo $dom->saveHTML($dom->documentElement); ?>
Output for 5.3.6 - 5.6.21, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
<html><head><link rel="stylesheet" href="http://www.foo.com/bar/baz.min.css" type="text/css" id="23434" foo="test" media="all"></head></html>
Output for 5.0.0 - 5.3.5
Warning: DOMDocument::saveHTML() expects exactly 0 parameters, 1 given in /in/dkN1e on line 10
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/dkN1e on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: domdocument in /in/dkN1e on line 4