<?php
class tes implements \ArrayAccess{
public $vari = [];
public function offsetExists($offset){
return isset($this->vari[$offset])?true:false;
}
public function offsetGet($offset){
return $this->vari[$offset];
}
public function offsetSet($offset, $value){
$this->vari[$offset] = $value;
}
public function offsetUnset($offset){
unset($this->vari[$offset]);
}
}
$t = new tes;
$t['s'] = 'aaaaaa';
echo $t['s'];
测试ArrayAccess
最新推荐文章于 2025-06-14 22:46:47 发布