3v4l.org

run code in 300+ PHP versions simultaneously
<?php class T { public function __get($property) { if (!isset($this->{$property})) { $this->{$property} = array(); } return $this->{$property}; } public function __set($key, $val) { $this->{$key} = $val; } } $testObj = new T(); $testObj->testArr; $testObj->testArr[] = 1; $testObj->testArr[] = 2; $testObj->testArr[] = 3; var_dump($testObj->testArr);

preferences:
29.04 ms | 402 KiB | 5 Q