ArrayAccess::offsetGet
(PHP 5 >= 5.0.0)
ArrayAccess::offsetGet — 获取一个偏移位置的值
说明
abstract public mixed ArrayAccess::offsetGet( mixed $offset)
返回指定偏移位置的值。
当检查一个偏移位置是否为 empty() 时,此方法被执行。
参数
offset
需要获取的偏移位置。
注释
Note:
Starting with PHP 5.3.4, the prototype checks were relaxed and it'spossible for implementations of this method to return by reference.This makes indirect modifications to the overloaded array dimensions of ArrayAccess objects possible.
A direct modification is one that replaces completely the value ofthe array dimension, as in $obj[6] = 7. Anindirect modification, on the other hand, only changes part of thedimension, or attempts to assign the dimension by reference toanother variable, as in $obj[6][7] = 7 or $var =& $obj[6]. Increments with ++ and decrements with --are also implemented in a way that requires indirect modification.
While direct modification triggers a call to ArrayAccess::offsetSet(), indirect modificationtriggers a call to ArrayAccess::offsetGet().In that case, the implementation of ArrayAccess::offsetGet() must be able to return byreference, otherwise an E_NOTICE message is raised.
返回值
可返回任何类型。
参见
◾ ArrayAccess::offsetExists() - 检查一个偏移位置是否存在
发表评论 取消回复