数组形式访问对象

//数组形式访问对对象
/**
* 1.通过继承PHP内置接口ArrayAccess来实现
* 2.必须实现方法:offsetExists,offsetGet,offsetSet,offsetUnset;
*/
classNewObjectimplementsArrayAccess
{
   /**
    * 检查一个偏移位置是否存在
    *@parammixed $offset
    *@returnbool
    */
   public functionoffsetExists($offset)
   {
       //处理逻辑代码
   }


   /**
    * 获取一个偏移位置的值
    *@parammixed $offset
    *@returnnull
    */
   public functionoffsetGet($offset)
   {
       //处理逻辑代码
   }


   /**
    * 设置一个偏移位置的值
    *@parammixed $offset
    *@parammixed $value
    */
   public functionoffsetSet($offset,$value)
   {
       //处理逻辑代码
   }

   /**
    * 复位一个偏移位置的值
    *@parammixed $offset
    *@returnnull
    */
   public functionoffsetUnset($offset)
   {
       //处理逻辑代码
   }
}

文章标题:数组形式访问对象
当前地址:http://hzjierui.cn/article/gcsdjh.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款