3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $domDoc = new DOMDocument; $domDoc->preserveWhiteSpace=false; $domDoc->loadXML(<<<XML <?xml version="1.0"?> <CONFIG> <APP-ID>166533e56</APP-ID> </CONFIG> XML ); $rootNode = $domDoc->documentElement; $config_root = $rootNode->getElementsByTagName("CONFIG"); $rootElt = $domDoc->createElement('USER-ID'); $subNode = $rootNode->appendChild($rootElt); $textNode = $domDoc->createTextNode('333265332f'); $subNode->appendChild($textNode); $rootElt = $domDoc->createElement('USER'); $sub2Node = $rootNode->appendChild($rootElt); $textNode = $domDoc->createTextNode('John'); $sub2Node->appendChild($textNode); $domDoc->formatOutput = true; //$domDoc->save('config.xml'); echo $domDoc->saveXML();
Output for 5.0.0 - 7.1.0
<?xml version="1.0"?> <CONFIG> <APP-ID>166533e56</APP-ID> <USER-ID>333265332f</USER-ID> <USER>John</USER> </CONFIG>
Output for 4.3.2 - 4.4.9
<br /> <b>Fatal error</b>: Cannot instantiate non-existent class: domdocument in <b>/in/6daNJ</b> on line <b>2</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/6daNJ</b> on line <b>2</b><br />