ArrayAccess 数组式接口
最后更新于:2022-04-02 02:26:24
[TOC]
## 实例
```
'A',
'b'=>'B',
];
public function offsetExists($offset)
{
return isset($this->arr[$offset]);
}
public function offsetGet($offset)
{
return $this->arr[$offset];
}
public function offsetSet($offset, $value)
{
$this->arr[$offset]=$value;
}
public function offsetUnset($offset)
{
unset($this->arr[$offset]);
}
}
$demo = new demo();
var_dump($demo['a']); // 'A'
unset($demo['a']);
var_dump(isset($demo['a'])); // false
$demo['c']='C';
var_dump($demo['c']); // 'C'
```
';