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'.'\n'); $sub2Node = $rootNode->appendChild($rootElt); $textNode = $domDoc->createTextNode('John'); $sub2Node->appendChild($textNode); $domDoc->formatOutput = true; //$domDoc->save('config.xml'); echo $domDoc->saveXML();
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught DOMException: Invalid Character Error in /in/8j3ca:21 Stack trace: #0 /in/8j3ca(21): DOMDocument->createElement('USER\\n') #1 {main} thrown in /in/8j3ca on line 21
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Fatal error: Uncaught exception 'DOMException' with message 'Invalid Character Error' in /in/8j3ca:21 Stack trace: #0 /in/8j3ca(21): DOMDocument->createElement() #1 {main}
Process exited with code 255.
Output for 5.4.27 - 5.4.45, 5.5.11 - 5.6.28
Fatal error: Uncaught exception 'DOMException' with message 'Invalid Character Error' in /in/8j3ca:21 Stack trace: #0 /in/8j3ca(21): DOMDocument->createElement('USER\\n') #1 {main} thrown in /in/8j3ca on line 21
Process exited with code 255.
Output for 5.0.3 - 5.1.1, 5.1.3 - 5.4.26, 5.5.0 - 5.5.10
Fatal error: Uncaught exception 'DOMException' with message 'Invalid Character Error' in /in/8j3ca:21 Stack trace: #0 /in/8j3ca(21): DOMDocument->createElement('USER\n') #1 {main} thrown in /in/8j3ca on line 21
Process exited with code 255.
Output for 5.1.2
Fatal error: Uncaught exception 'DOMException' with message 'Invalid Character Error' in /in/8j3ca:22 Stack trace: #0 /in/8j3ca(22): DOMDocument->createElement('USER\n') #1 {main} thrown in /in/8j3ca on line 22
Process exited with code 255.
Output for 5.0.0 - 5.0.2
Fatal error: Uncaught exception 'DOMException' with message 'Invalid Character Error' in /in/8j3ca:21 Stack trace: #0 {main} thrown in /in/8j3ca on line 21
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/8j3ca on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: domdocument in /in/8j3ca on line 2