Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 149

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!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 set</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="arrayaccess.offsetget.html">ArrayAccess::offsetGet</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="arrayaccess.offsetunset.html">ArrayAccess::offsetUnset</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.offsetset" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ArrayAccess::offsetSet</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.0.0)</p><p class="refpurpose"><span class="refname">ArrayAccess::offsetSet</span> &mdash; <span class="dc-title">Offset to set</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-arrayaccess.offsetset-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">abstract</span> <span class="modifier">public</span> <span class="type"><span class="type void">void</span></span> <span class="methodname"><strong>ArrayAccess::offsetSet</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>
   , <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>
   )</div>

  <p class="para rdfs-comment">
   Assigns a value to the specified offset.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-arrayaccess.offsetset-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 assign the value to.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">value</code></em></span>
     <dd>

      <p class="para">
       The value to set.
      </p>
     </dd>

    </dt>

   </dl>

  </p>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-arrayaccess.offsetset-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   No value is returned.
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-arrayaccess.offsetset-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    The <em><code class="parameter">offset</code></em> parameter will be set to <strong><code>NULL</code></strong> if
    another value is not available, like in the following example.
    <div class="informalexample">
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$arrayaccess</span><span style="color: #007700">[]&nbsp;=&nbsp;</span><span style="color: #DD0000">"first&nbsp;value"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$arrayaccess</span><span style="color: #007700">[]&nbsp;=&nbsp;</span><span style="color: #DD0000">"second&nbsp;value"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$arrayaccess</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

     <p class="para">The above example will output:</p>
     <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [0] =&gt; first value
    [1] =&gt; second value
)
</pre></div>
     </div>
    </div>
   </p>
  </p></blockquote>
  
  <blockquote class="note"><p><strong class="note">Note</strong>: 
    <p class="para">
      This function is not called in assignments by reference and otherwise
      indirect changes to array dimensions overloaded with
      <a href="class.arrayaccess.html" class="classname">ArrayAccess</a> (indirect in the sense they are
      made not by changing the dimension directly, but by changing a
      sub-dimension or sub-property or assigning the array dimension by
      reference to another variable).
      Instead,  <span class="function"><a href="arrayaccess.offsetget.html" class="function">ArrayAccess::offsetGet()</a></span> is called. The
      operation will only be successful if that method returns by reference,
      which is only possible since PHP 5.3.4.
    </p>
  </p></blockquote>
 </div>




</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="arrayaccess.offsetget.html">ArrayAccess::offsetGet</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="arrayaccess.offsetunset.html">ArrayAccess::offsetUnset</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>