3v4l.org

run code in 300+ PHP versions simultaneously
<?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 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: Undefined variable $doc in /in/SJiLC on line 25 Warning: Attempt to read property "documentElement" on null in /in/SJiLC on line 25 Warning: Attempt to read property "childNodes" on null in /in/SJiLC on line 25 Warning: foreach() argument must be of type array|object, null given in /in/SJiLC on line 27
Output for 7.2.17 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined variable: doc in /in/SJiLC on line 25 Notice: Trying to get property 'documentElement' of non-object in /in/SJiLC on line 25 Notice: Trying to get property 'childNodes' of non-object in /in/SJiLC on line 25 Warning: Invalid argument supplied for foreach() in /in/SJiLC on line 27
Output for 7.3.32 - 7.3.33
Warning: Invalid argument supplied for foreach() in /in/SJiLC on line 27
Output for 5.1.3 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33
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.4 - 5.0.5, 5.1.0 - 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.3.11, 4.4.0 - 4.4.9

preferences:
218.19 ms | 402 KiB | 340 Q