<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Offset to retrieve</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="arrayaccess.offsetexists.html">ArrayAccess::offsetExists</a></div> <div class="next" style="text-align: right; float: right;"><a href="arrayaccess.offsetset.html">ArrayAccess::offsetSet</a></div> <div class="up"><a href="class.arrayaccess.html">ArrayAccess</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="arrayaccess.offsetget" class="refentry"> <div class="refnamediv"> <h1 class="refname">ArrayAccess::offsetGet</h1> <p class="verinfo">(PHP 5 >= 5.0.0)</p><p class="refpurpose"><span class="refname">ArrayAccess::offsetGet</span> — <span class="dc-title">Offset to retrieve</span></p> </div> <div class="refsect1 description" id="refsect1-arrayaccess.offsetget-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">abstract</span> <span class="modifier">public</span> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>ArrayAccess::offsetGet</strong></span> ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$offset</code></span> )</div> <p class="para rdfs-comment"> Returns the value at specified offset. </p> <p class="para"> This method is executed when checking if offset is <span class="function"><a href="function.empty.html" class="function">empty()</a></span>. </p> </div> <div class="refsect1 parameters" id="refsect1-arrayaccess.offsetget-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">offset</code></em></span> <dd> <p class="para"> The offset to retrieve. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 notes" id="refsect1-arrayaccess.offsetget-notes"> <h3 class="title">Notes</h3> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> Starting with PHP 5.3.4, the prototype checks were relaxed and it's possible for implementations of this method to return by reference. This makes indirect modifications to the overloaded array dimensions of <a href="class.arrayaccess.html" class="classname">ArrayAccess</a> objects possible. </p> <p class="para"> A direct modification is one that replaces completely the value of the array dimension, as in <em>$obj[6] = 7</em>. 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 <em>$obj[6][7] = 7</em> or <em>$var =& $obj[6]</em>. Increments with <em>++</em> and decrements with <em>--</em> are also implemented in a way that requires indirect modification. </p> <p class="para"> While direct modification triggers a call to <span class="function"><a href="arrayaccess.offsetset.html" class="function">ArrayAccess::offsetSet()</a></span>, indirect modification triggers a call to <span class="function"><strong>ArrayAccess::offsetGet()</strong></span>. In that case, the implementation of <span class="function"><strong>ArrayAccess::offsetGet()</strong></span> must be able to return by reference, otherwise an <strong><code>E_NOTICE</code></strong> message is raised. </p> </p></blockquote> </div> <div class="refsect1 returnvalues" id="refsect1-arrayaccess.offsetget-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Can return all value types. </p> </div> <div class="refsect1 seealso" id="refsect1-arrayaccess.offsetget-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="methodname"><a href="arrayaccess.offsetexists.html" class="methodname" rel="rdfs-seeAlso">ArrayAccess::offsetExists()</a> - Whether a offset exists</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="arrayaccess.offsetexists.html">ArrayAccess::offsetExists</a></div> <div class="next" style="text-align: right; float: right;"><a href="arrayaccess.offsetset.html">ArrayAccess::offsetSet</a></div> <div class="up"><a href="class.arrayaccess.html">ArrayAccess</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>