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 = $val; } else { $this->$val = $val; } } } } $array = ["database"=>["host"=>"localhost","dbname"=>"mydb","user"=>"root","password"=>""]]; $xml = new XML($array); echo($xml->{"database"}->{"host"});
based on s8qd3
Output for 7.2.0
Notice: Trying to get property 'host' of non-object in /in/qUh3d on line 16
Output for 5.4.0 - 7.1.10
Notice: Trying to get property of non-object in /in/qUh3d on line 16
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/qUh3d on line 14
Process exited with code 255.