3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class testclass{ public $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 = $this->xmlRequestDom->documentElement->childNodes; foreach($children as $child) { if($child->nodeType != XML_ELEMENT_NODE) continue; echo $child->nodeName; } } } $newxml = "<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>"; $myParamObj = new testclass($newxml);
Output for 5.0.0 - 7.1.0
Warning: DOMDocument::loadXML(): Namespace prefix tridas on object is not defined in Entity, line: 1 in /in/iXKkb on line 15 Warning: DOMDocument::loadXML(): Namespace prefix tridas on title is not defined in Entity, line: 2 in /in/iXKkb on line 15 Warning: DOMDocument::loadXML(): Namespace prefix tridas on type is not defined in Entity, line: 3 in /in/iXKkb on line 15 Warning: DOMDocument::loadXML(): Namespace prefix tridas on genericField is not defined in Entity, line: 4 in /in/iXKkb on line 15 tridas:titletridas:typetridas:genericField
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/iXKkb on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/iXKkb on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/iXKkb on line 4
Process exited with code 255.