3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class testclass{ var $xmlRequestDom = NULL; function __construct($xmlrequest) { if (gettype($xmlrequest)=='object') { $this->xmlRequestDom = $xmlrequest; } else { $this->xmlRequestDom = new DomDocument(); $this->xmlRequestDom->loadXML($xmlrequest); } $this->setParamsFromXMLRequest(); } function setParamsFromXMLRequest() { $children = $doc->documentElement->childNodes; foreach($children as $child) { if($child->nodeType != XML_ELEMENT_NODE) continue; echo $child->nodeName; } } } $newxml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <c:tellervo xmlns:c=\"http://www.tellervo.org/schema/1.0\" xmlns:gml=\"http://www.opengis.net/gml\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:tridas=\"http://www.tridas.org/1.2.2\"> <c:request type=\"create\"> <tridas:object> <tridas:title>ppp</tridas:title> <tridas:type normalStd=\"Tellervo\" normalId=\"1\" normal=\"Site\" /> <tridas:genericField name=\"tellervo.objectLabCode\">ppp</tridas:genericField> </tridas:object> </c:request> </c:tellervo>"; $myParamObj = new testclass($newxml);
Output for 5.1.3 - 5.6.28, 7.0.0 - 7.1.0
Notice: Undefined variable: doc in /in/SJiLC on line 25 Notice: Trying to get property of non-object in /in/SJiLC on line 25 Notice: Trying to get property of non-object in /in/SJiLC on line 25 Warning: Invalid argument supplied for foreach() in /in/SJiLC on line 27
Output for hhvm-3.10.0 - 3.12.0
Notice: Undefined variable: doc in /in/SJiLC on line 25 Notice: Cannot access property on non-object in /in/SJiLC on line 25 Notice: Cannot access property on non-object in /in/SJiLC on line 25 Warning: Invalid argument supplied for foreach() in /in/SJiLC on line 32
Output for 5.0.4 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/SJiLC on line 4 Notice: Undefined variable: doc in /in/SJiLC on line 25 Notice: Trying to get property of non-object in /in/SJiLC on line 25 Notice: Trying to get property of non-object in /in/SJiLC on line 25 Warning: Invalid argument supplied for foreach() in /in/SJiLC on line 27
Output for 5.0.0 - 5.0.3
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/SJiLC on line 4 Notice: Undefined variable: doc in /in/SJiLC on line 25 Notice: Trying to get property of non-object in /in/SJiLC on line 25 Notice: Trying to get property of non-object in /in/SJiLC on line 25 Warning: Invalid argument supplied for foreach() in /in/SJiLC on line 27
Output for 4.3.0 - 4.4.9