3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php //creating an XML document $dom = new DOMDocument('1.0'); $dom->xmlStandalone = false; //create element manifest $manfiestNode = $dom->createElement('manifest',""); $dom->importNode($manfiestNode); //create attribute identifier $manfiestNodeAttr = $dom->createAttribute('identifier'); //value for the manifest node identifier value $date = new DateTime(); $manfiestNodeAttr->value = 'course_'.date_format($date,'U'); //append attribute to the manifest element $manfiestNode->appendChild($manfiestNodeAttr); $manfiestNode->appendChild($dom->createAttribute('xmlns:xsi'))->appendChild($dom->createTextNode("http://www.w3.org/2001/XMLSchema-instance")); //add metadata element under manifest node $metaData = $dom->createElement('metadata',''); //add metadata element to manifest node $manfiestNode->appendChild($metaData); //create schema and schemaversion element under metatag $schema = $dom->createElement('schema','ADL SCORM'); $schemaVersion = $dom->createElement('schemaversion', '2004 3rd Edition'); //create schema and schemaversion element under metatag $metaData->appendChid($schema); $metaData->appendChid($schemaVersion); //append manifest element to the document $dom->appendChild($manfiestNode); var_dump($dom->saveXML());
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to undefined method DOMElement::appendChid() in /in/5BhgC:34 Stack trace: #0 {main} thrown in /in/5BhgC on line 34
Process exited with code 255.
Output for 5.2.3 - 5.2.17, 5.5.0 - 5.6.28, hhvm-3.10.0 - 3.12.0
Fatal error: Call to undefined method DOMElement::appendChid() in /in/5BhgC on line 34
Process exited with code 255.
Output for 5.4.0 - 5.4.45
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.' in /in/5BhgC:15 Stack trace: #0 /in/5BhgC(15): DateTime->__construct() #1 {main} thrown in /in/5BhgC on line 15
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead' in /in/5BhgC:15 Stack trace: #0 /in/5BhgC(15): DateTime->__construct() #1 {main} thrown in /in/5BhgC on line 15
Process exited with code 255.
Output for 5.2.0 - 5.2.2
<br /> <b>Fatal error</b>: Call to undefined method DOMElement::appendChid() in <b>/in/5BhgC</b> on line <b>34</b><br />
Process exited with code 255.
Output for 5.0.0 - 5.1.6
<br /> <b>Fatal error</b>: Class 'DateTime' not found in <b>/in/5BhgC</b> on line <b>15</b><br />
Process exited with code 255.
Output for 4.4.2 - 4.4.9
<br /> <b>Parse error</b>: syntax error, unexpected T_OBJECT_OPERATOR in <b>/in/5BhgC</b> on line <b>21</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
<br /> <b>Parse error</b>: parse error, unexpected T_OBJECT_OPERATOR in <b>/in/5BhgC</b> on line <b>21</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error in <b>/in/5BhgC</b> on line <b>21</b><br />
Process exited with code 255.