3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class U { public $id; public $name; } $a = ['id' => 123, 'name' => 'Me']; $o = (object)$a; var_dump($o); $a0 = new ArrayObject($a); $a1 = new ArrayObject($a, ArrayObject::STD_PROP_LIST); $a2 = new ArrayObject($a, ArrayObject::ARRAY_AS_PROPS); $a3 = new ArrayObject($a, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS); $a3x = new ArrayObject($a, ArrayObject::STD_PROP_LIST & ArrayObject::ARRAY_AS_PROPS); var_dump($a0); var_dump($a0->name); var_dump($a1->name); var_dump($a2->name); var_dump($a3->name); var_dump($a3x->name);
based on lXfjM
Output for 5.6.0 - 7.3.0beta1
object(stdClass)#1 (2) { ["id"]=> int(123) ["name"]=> string(2) "Me" } object(ArrayObject)#2 (1) { ["storage":"ArrayObject":private]=> array(2) { ["id"]=> int(123) ["name"]=> string(2) "Me" } } Notice: Undefined property: ArrayObject::$name in /in/dAXjk on line 18 NULL Notice: Undefined property: ArrayObject::$name in /in/dAXjk on line 19 NULL string(2) "Me" string(2) "Me" Notice: Undefined property: ArrayObject::$name in /in/dAXjk on line 22 NULL