3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyClass { private $string; private $array; public function __set($attribute, $value) { $this->$attribute = $value; } public function __get($attribute) { if (isset($attribute)) { return $this->$attribute; } } } $obg = new MyClass(); $obg->string = 'Hey it works!'; $obg->array = new ArrayObject(['This works', 'too!']); $obg->array['key'] = "This will throw 'Indirect modification of overloaded property MyClass::\$array has no effect'"; print_r($obg->array->getArrayCopy());

preferences:
35.47 ms | 402 KiB | 5 Q