class ResultSet implements \ArrayAccess { /** * 返回的错误码 **/ public $code; /** * 返回的错误信息 **/ public $msg; /** * Returns whether there is an element at the specified offset. * This method is required by the SPL interface [[\ArrayAccess]]. * It is implicitly called when you use something like `isset($model[$offset])`. * @param mixed $offset the offset to check on * @return boolean */ public function offsetExists($offset) { return $this->$offset !== null; } /** * Returns the element at the specified offset. * This method is required by the SPL interface [[\ArrayAccess]]. * It is implicitly called when you use something like `$value = $model[$offset];`. * @param mixed $offset the offset to retrieve element. * @return mixed the element at the offset, null if no element is found at the offset */ public function offsetGet($offset) { return $this->$offset; } /** * Sets the element at the specified offset. * This method is required by the SPL interface [[\ArrayAccess]]. * It is implicitly called when you use something like `$model[$offset] = $item;`. * @param integer $offset the offset to set element * @param mixed $item the element value */ public function offsetSet($offset, $item) { $this->$offset = $item; } /** * Sets the element value at the specified offset to null. * This method is required by the SPL interface [[\ArrayAccess]]. * It is implicitly called when you use something like `unset($model[$offset])`. * @param mixed $offset the offset to unset element */ public function offsetUnset($offset) { $this->$offset = null; } }
PHP预定义接口之 ArrayAccess
最新推荐文章于 2022-09-19 15:28:23 发布