PHP 对象,如数组
我需要能够像这样设置我的对象:
$obj->foo = 'bar';
然后我需要像这样使用它作为数组:
if($obj['foo'] == 'bar'){
//more code here
}
我需要能够像这样设置我的对象:
$obj->foo = 'bar';
然后我需要像这样使用它作为数组:
if($obj['foo'] == 'bar'){
//more code here
}
只需添加到您的类并添加所需的方法:implements ArrayAccess