3v4l.org

run code in 200+ PHP versions simultaneously
<?php class Thing extends ArrayObject { public function __construct(array $data) { parent::__construct($data, self::ARRAY_AS_PROPS); } public function offsetSet($index, $value) { parent::offsetSet($index, $value); return $this; } public function offsetGet($index) { if ($this->offsetExists($index)) { return parent::offsetGet($index); } return null; } } $test = new Thing([]); $test->dynamic['key'] = ['is-set' => 'up to 7.1.3']; var_dump($test);
based on em3Sa
Output for 7.1.4 - 7.4.0
object(Thing)#1 (1) { ["storage":"ArrayObject":private]=> array(0) { } }
Output for 5.6.0 - 7.1.3
object(Thing)#1 (1) { ["storage":"ArrayObject":private]=> array(1) { ["dynamic"]=> array(1) { ["key"]=> array(1) { ["is-set"]=> string(11) "up to 7.1.3" } } } }