3v4l.org

run code in 200+ php & hhvm versions
<?php $dom = new DOMDocument(); $dom->loadXML("<root/>"); $doc = $dom->documentElement; // & < > escaped $doc->appendChild($dom->createTextNode("& \" ' < >")); // & " < > escaped $attr = $dom->createAttribute("attr"); $attr->appendChild($dom->createTextNode("& \" ' < >")); $doc->appendChild($attr); echo $dom->saveXML();
Output for 5.0.0 - 5.6.30, hhvm-3.10.1 - 3.17.3, 7.0.0 - 7.3.1
<?xml version="1.0"?> <root attr="&amp; &quot; ' &lt; &gt;">&amp; " ' &lt; &gt;</root>
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/DQh17 on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: domdocument in /in/DQh17 on line 3