array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'en', ), 'this' => array ( 0 => 'arrayaccess.offsetget.php', 1 => 'ArrayAccess::offsetGet', ), 'up' => array ( 0 => 'class.arrayaccess.php', 1 => 'ArrayAccess', ), 'prev' => array ( 0 => 'arrayaccess.offsetexists.php', 1 => 'ArrayAccess::offsetExists', ), 'next' => array ( 0 => 'arrayaccess.offsetset.php', 1 => 'ArrayAccess::offsetSet', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'language/predefined/arrayaccess/offsetget.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5, PHP 7, PHP 8)
ArrayAccess::offsetGet — Offset to retrieve
Returns the value at specified offset.
This method is executed when checking if offset is empty().
offset
The offset to retrieve.
Can return all value types.
Note:
It's possible 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 of the array dimension, as in
$obj[6] = 7
. An indirect modification, on the other hand, only changes part of the dimension, or attempts to assign the dimension by reference to another 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 modification triggers a call to ArrayAccess::offsetGet(). In that case, the implementation of ArrayAccess::offsetGet() must be able to return by reference, otherwise an
E_NOTICE
message is raised.