3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class XML { public function __CONSTRUCT($array) { foreach($array as $key => $val) { if(isset($key) && $key) { $this->$key; bindTo($this->$key, $this->$val); } else { $this->$val; bindTo($this->$val, $this->$val); } } } } $array = ["database"=>["host"=>"localhost","dbname"=>"mydb","user"=>"root","password"=>""]]; $xml = new XML($array); echo($xml->{"database"}->{"host"});
based on 2XgBW
Output for 7.0.0 - 7.2.0
Notice: Undefined property: XML::$database in /in/WOgj9 on line 6 Fatal error: Uncaught Error: Call to undefined function bindTo() in /in/WOgj9:7 Stack trace: #0 /in/WOgj9(17): XML->__CONSTRUCT(Array) #1 {main} thrown in /in/WOgj9 on line 7
Process exited with code 255.
Output for 5.4.0 - 5.6.28
Notice: Undefined property: XML::$database in /in/WOgj9 on line 6 Fatal error: Call to undefined function bindTo() in /in/WOgj9 on line 7
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/WOgj9 on line 16
Process exited with code 255.