<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.splobjectstorage.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'splobjectstorage.gethash.php',
    1 => 'SplObjectStorage::getHash',
    2 => 'Calculate a unique identifier for the contained objects',
  ),
  'up' => 
  array (
    0 => 'class.splobjectstorage.php',
    1 => 'SplObjectStorage',
  ),
  'prev' => 
  array (
    0 => 'splobjectstorage.detach.php',
    1 => 'SplObjectStorage::detach',
  ),
  'next' => 
  array (
    0 => 'splobjectstorage.getinfo.php',
    1 => 'SplObjectStorage::getInfo',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/spl/splobjectstorage/gethash.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="splobjectstorage.gethash" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SplObjectStorage::getHash</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.4.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">SplObjectStorage::getHash</span> &mdash; <span class="dc-title">
   Calculate a unique identifier for the contained objects
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-splobjectstorage.gethash-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>SplObjectStorage::getHash</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.object.php" class="type object">object</a></span> <code class="parameter">$object</code></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="para rdfs-comment">
   This method calculates an identifier for the objects added to an
   <span class="classname"><a href="class.splobjectstorage.php" class="classname">SplObjectStorage</a></span> object.
  </p>
  <p class="para">
   The implementation in <span class="classname"><a href="class.splobjectstorage.php" class="classname">SplObjectStorage</a></span> returns
   the same value as <span class="function"><a href="function.spl-object-hash.php" class="function">spl_object_hash()</a></span>.
  </p>
  <p class="para">
   The storage object will never contain more than one object with the same identifier.
   As such, it can be used to implement a set (a collection of unique values)
   where the quality of an object being unique is determined by the value
   returned by this function being unique.
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-splobjectstorage.gethash-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <dl>
   
    <dt><code class="parameter">object</code></dt>
    <dd>
     <p class="para">
      The object whose identifier is to be calculated.
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-splobjectstorage.gethash-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   A <span class="type"><a href="language.types.string.php" class="type string">string</a></span> with the calculated identifier.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-splobjectstorage.gethash-errors">
  <h3 class="title">Errori/Eccezioni</h3>
  <p class="para">
   A <span class="classname"><a href="class.runtimeexception.php" class="classname">RuntimeException</a></span> is thrown when the returned
   value is not a <span class="type"><a href="language.types.string.php" class="type string">string</a></span>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-splobjectstorage.gethash-examples">
  <h3 class="title">Esempi</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>SplObjectStorage::getHash()</strong></span> example</strong></p>
<div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class </span><span style="color: #0000BB">OneSpecimenPerClassStorage </span><span style="color: #007700">extends </span><span style="color: #0000BB">SplObjectStorage </span><span style="color: #007700">{<br />    public function </span><span style="color: #0000BB">getHash</span><span style="color: #007700">(</span><span style="color: #0000BB">$o</span><span style="color: #007700">) {<br />        return </span><span style="color: #0000BB">get_class</span><span style="color: #007700">(</span><span style="color: #0000BB">$o</span><span style="color: #007700">);<br />    }<br />}<br />class </span><span style="color: #0000BB">A </span><span style="color: #007700">{}<br /><br /></span><span style="color: #0000BB">$s </span><span style="color: #007700">= new </span><span style="color: #0000BB">OneSpecimenPerClassStorage</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$o1 </span><span style="color: #007700">= new </span><span style="color: #0000BB">stdClass</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$o2 </span><span style="color: #007700">= new </span><span style="color: #0000BB">stdClass</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$o3 </span><span style="color: #007700">= new </span><span style="color: #0000BB">A</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$s</span><span style="color: #007700">[</span><span style="color: #0000BB">$o1</span><span style="color: #007700">] = </span><span style="color: #0000BB">1</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">//$o2 is considered equal to $o1 so the value is replaced<br /></span><span style="color: #0000BB">$s</span><span style="color: #007700">[</span><span style="color: #0000BB">$o2</span><span style="color: #007700">] = </span><span style="color: #0000BB">2</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$s</span><span style="color: #007700">[</span><span style="color: #0000BB">$o3</span><span style="color: #007700">] = </span><span style="color: #0000BB">3</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//these are considered equal to the objects before<br />//so they can be used to access the values stored under them<br /></span><span style="color: #0000BB">$p1 </span><span style="color: #007700">= new </span><span style="color: #0000BB">stdClass</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$p2 </span><span style="color: #007700">= new </span><span style="color: #0000BB">A</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">$s</span><span style="color: #007700">[</span><span style="color: #0000BB">$p1</span><span style="color: #007700">], </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">$s</span><span style="color: #007700">[</span><span style="color: #0000BB">$p2</span><span style="color: #007700">], </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Il precedente esempio visualizzerà
qualcosa simile a:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">2
3</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-splobjectstorage.gethash-seealso">
  <h3 class="title">Vedere anche:</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.spl-object-hash.php" class="function" rel="rdfs-seeAlso">spl_object_hash()</a> - Return hash id for given object</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>