3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Node { function &__get($name) { $value = null; $this->$name = &$value; return $value; } } $node = new Node; $node->title = 'foo'; $node->menu['enabled'] = 1; $node->rer_fields[] = 'bar'; var_dump($node);
Output for 5.1.0 - 5.1.6, 5.2.1 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
object(Node)#1 (3) { ["title"]=> string(3) "foo" ["menu"]=> array(1) { ["enabled"]=> int(1) } ["rer_fields"]=> array(1) { [0]=> string(3) "bar" } }
Output for 5.2.0
Notice: Indirect modification of overloaded property Node::$menu has no effect in /in/BNCk0 on line 13 Notice: Indirect modification of overloaded property Node::$rer_fields has no effect in /in/BNCk0 on line 14 object(Node)#1 (3) { ["title"]=> string(3) "foo" ["menu"]=> &NULL ["rer_fields"]=> &NULL }
Output for 5.0.5
Notice: Undefined property: Node::$menu in /in/BNCk0 on line 6 Fatal error: Cannot assign by reference to overloaded object in /in/BNCk0 on line 6
Process exited with code 255.
Output for 5.0.4
Notice: Undefined property: Node::$menu in /in/BNCk0 on line 6 Notice: Undefined property: Node::$rer_fields in /in/BNCk0 on line 6
Process exited with code 139.
Output for 5.0.0 - 5.0.3
Fatal error: Cannot access undefined property for object with overloaded property access in /in/BNCk0 on line 13
Process exited with code 255.
Output for 4.3.0 - 4.4.9
object(node)(3) { ["title"]=> string(3) "foo" ["menu"]=> array(1) { ["enabled"]=> int(1) } ["rer_fields"]=> array(1) { [0]=> string(3) "bar" } }