数组形式访问对象-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

数组形式访问对象

//数组形式访问对对象
/**
* 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://kswsj.cn/article/gcsdjh.html

其他资讯