3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $xmlrequest = new DOMDocument; $xmlrequest->preserveWhiteSpace = false; $xmlrequest->loadXML(<<<XML <?xml version="1.0"?> <request> <APP-ID>166533e56</APP-ID> </request> XML ); $rootNode = $xmlrequest->documentElement; $request_root = $rootNode->getElementsByTagName("request"); foreach($xmldata as $k => $v){ $rootElt = $xmlrequest->createElement('email'); $subNode = $rootNode->appendChild($rootElt); $subrootElt = $xmlrequest->createElement('recipient'); $subsubNode = $subNode->appendChild($subrootElt); $textNode = $xmlrequest->createTextNode(md5(strtolower($v->contacts_emailaddress))); $subsubNode->appendChild($textNode); $subrootElt = $xmlrequest->createElement('list'); $subsub2Node = $subNode->appendChild($subrootElt); $textNode = $xmlrequest->createTextNode($this->list_id); $subsub2Node->appendChild($textNode); $subrootElt = $xmlrequest->createElement('domain'); $subsub3Node = $subNode->appendChild($subrootElt); $textNode = $xmlrequest->createTextNode($v->contacts_domainname); $subsub3Node->appendChild($textNode); } $xmlrequest->formatOutput = true; //$domDoc->save('config.xml'); echo $xmlrequest->saveXML(); /*$xmlrequest .= "</request>".'<br/>';*/ return $xmlrequest;
Output for 5.1.0 - 5.1.1, 5.1.3 - 7.1.0
Notice: Undefined variable: xmldata in /in/tY0io on line 13 Warning: Invalid argument supplied for foreach() in /in/tY0io on line 13 <?xml version="1.0"?> <request> <APP-ID>166533e56</APP-ID> </request>
Output for 5.1.2
Notice: Undefined variable: xmldata in /in/tY0io on line 14 Warning: Invalid argument supplied for foreach() in /in/tY0io on line 14 <?xml version="1.0"?> <request> <APP-ID>166533e56</APP-ID> </request>
Output for 5.0.0 - 5.0.5
Warning: Invalid argument supplied for foreach() in /in/tY0io on line 13 <?xml version="1.0"?> <request> <APP-ID>166533e56</APP-ID> </request>
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: domdocument in /in/tY0io 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/tY0io on line 2