3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = new DOMdocument("1.0", "UTF-8"); $xml->preserveWhiteSpace = true; $root = $xml->createElement("Comprobante"); $root = $xml->appendChild($root); $xml->appendChild($attr); $attr1 = $xml->createTextNode("version"); $xml->appendChild($attr1); $attr = $xml->createTextNode($root->setAttribute("LugarExpedicion", "CULIACÁN, SINALOA")); //$root->setAttribute("LugarExpedicion", "CULIACÁN, SINALOA"); //$root->setAttribute("version", "3.2"); /*$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'); $sub2Node = $rootNode->appendChild($rootElt); $textNode = $domDoc->createTextNode('John'); $sub2Node->appendChild($textNode);*/ $xml->formatOutput = true; //$domDoc->save('config.xml'); echo $xml->saveXML();
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.15, 8.5.0 - 8.5.1
Warning: Undefined variable $attr in /in/VifEa on line 7 Fatal error: Uncaught TypeError: DOMNode::appendChild(): Argument #1 ($node) must be of type DOMNode, null given in /in/VifEa:7 Stack trace: #0 /in/VifEa(7): DOMNode->appendChild(NULL) #1 {main} thrown in /in/VifEa on line 7
Process exited with code 255.
Output for 8.3.28
/bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28)
Process exited with code 1.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined variable: attr in /in/VifEa on line 7 Fatal error: Uncaught TypeError: Argument 1 passed to DOMNode::appendChild() must be an instance of DOMNode, null given in /in/VifEa:7 Stack trace: #0 /in/VifEa(7): DOMNode->appendChild(NULL) #1 {main} thrown in /in/VifEa on line 7
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Fatal error: Uncaught TypeError: Argument 1 passed to DOMNode::appendChild() must be an instance of DOMNode, null given in /in/VifEa:7 Stack trace: #0 /in/VifEa(7): DOMNode->appendChild(NULL) #1 {main} thrown in /in/VifEa on line 7
Process exited with code 255.
Output for 5.2.6 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28
Notice: Undefined variable: attr in /in/VifEa on line 7 Catchable fatal error: Argument 1 passed to DOMNode::appendChild() must be an instance of DOMNode, null given in /in/VifEa on line 7
Process exited with code 255.
Output for 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.5
Notice: Undefined variable: attr in /in/VifEa on line 7 Warning: DOMNode::appendChild() expects parameter 1 to be DOMNode, null given in /in/VifEa on line 7 Warning: DOMDocument::createTextNode() expects parameter 1 to be string, object given in /in/VifEa on line 10 <?xml version="1.0" encoding="UTF-8"?> <Comprobante LugarExpedicion="CULIACÁN, SINALOA"/> version
Output for 5.0.4
Notice: Undefined variable: attr in /in/VifEa on line 7 Warning: appendChild() expects parameter 1 to be DOMNode, null given in /in/VifEa on line 7 Warning: createTextNode() expects parameter 1 to be string, object given in /in/VifEa on line 10 <?xml version="1.0" encoding="UTF-8"?> <Comprobante LugarExpedicion="CULIACÁN, SINALOA"/> version
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: attr in /in/VifEa on line 7 Warning: appendChild() expects parameter 1 to be DOMNode, null given in /in/VifEa on line 7 Warning: createTextNode() expects parameter 1 to be string, object given in /in/VifEa on line 10 <?xml version="1.0" encoding="UTF-8"?> <Comprobante LugarExpedicion="CULIACÁN, SINALOA"/> version
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/VifEa 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/VifEa on line 2

preferences:
197.95 ms | 418 KiB | 5 Q