3v4l.org

run code in 300+ PHP versions simultaneously
<?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 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Deprecated: Creation of dynamic property Node::$title is deprecated in /in/BNCk0 on line 12 Deprecated: Creation of dynamic property Node::$menu is deprecated in /in/BNCk0 on line 6 Deprecated: Creation of dynamic property Node::$rer_fields is deprecated in /in/BNCk0 on line 6 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.1.0 - 5.1.6, 5.2.1 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
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.3.11, 4.4.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" } }

preferences:
273.51 ms | 402 KiB | 459 Q