3v4l.org

run code in 300+ 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)) { $this[$index] = null; } return $this[$index]; } } $test = new Thing([]); $test->dynamic['key'] = ['is-set' => 'up to 7.1.3']; var_dump($test);

preferences:
53.7 ms | 402 KiB | 5 Q