$offset; } public function offsetSet($offset, $value) { $this->$offset = $value; } public function offsetUnset($offset) { unset($this->$offset); } } // => Fatal error: Class 'Test' not found // --------------------------------------------------- class Test implements ArrayAccess { public function offsetExists($offset) { return property_exists($this, $offset); } public function offsetGet($offset) { return $this->$offset; } public function offsetSet($offset, $value) { $this->$offset = $value; } public function offsetUnset($offset) { unset($this->$offset); } } $p = new Test(); $p['foo']=1; var_dump($p); // => object(Test)#1 (1) { ["foo"]=> int(1) } ?>