3v4l.org

run code in 200+ 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-NAME'.PHP_EOL); $sub2Node = $rootNode->appendChild($rootElt); $textNode = $domDoc->createTextNode('John'); $sub2Node->appendChild($textNode); $domDoc->formatOutput = true; //$domDoc->save('config.xml'); echo $domDoc->saveXML();
based on AZqpf
Output for 7.0.0 - 7.3.0beta1
Fatal error: Uncaught DOMException: Invalid Character Error in /in/eRkgg:21 Stack trace: #0 /in/eRkgg(21): DOMDocument->createElement('USER-NAME\n') #1 {main} thrown in /in/eRkgg on line 21
Process exited with code 255.
Output for hhvm-3.12.14 - 3.17.3
Fatal error: Uncaught exception 'DOMException' with message 'Invalid Character Error' in /in/eRkgg:21 Stack trace: #0 /in/eRkgg(21): DOMDocument->createElement() #1 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Fatal error: Uncaught exception 'DOMException' with message 'Invalid Character Error' in /in/eRkgg:21 Stack trace: #0 /in/eRkgg(21): DOMDocument->createElement('USER-NAME\n') #1 {main} thrown in /in/eRkgg on line 21
Process exited with code 255.