<!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>Return hash id for given object</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.spl-classes.html">spl_classes</a></div> <div class="next" style="text-align: right; float: right;"><a href="spl.files.html">File Handling</a></div> <div class="up"><a href="ref.spl.html">SPL Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.spl-object-hash" class="refentry"> <div class="refnamediv"> <h1 class="refname">spl_object_hash</h1> <p class="verinfo">(PHP 5 >= 5.2.0)</p><p class="refpurpose"><span class="refname">spl_object_hash</span> — <span class="dc-title"> Return hash id for given object </span></p> </div> <div class="refsect1 description" id="refsect1-function.spl-object-hash-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><strong>spl_object_hash</strong></span> ( <span class="methodparam"><span class="type">object</span> <code class="parameter">$obj</code></span> )</div> <p class="para rdfs-comment"> This function returns a unique identifier for the object. This id can be used as a hash key for storing objects or for identifying an object. </p> </div> <div class="refsect1 parameters" id="refsect1-function.spl-object-hash-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">object</code></em></span> <dd> <p class="para"> Any object. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.spl-object-hash-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> A string that is unique for each currently existing object and is always the same for each object. </p> </div> <div class="refsect1 examples" id="refsect1-function.spl-object-hash-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-3921"> <p><strong>Example #1 A <span class="function"><strong>spl_object_hash()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$id </span><span style="color: #007700">= </span><span style="color: #0000BB">spl_object_hash</span><span style="color: #007700">(</span><span style="color: #0000BB">$object</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$storage</span><span style="color: #007700">[</span><span style="color: #0000BB">$id</span><span style="color: #007700">] = </span><span style="color: #0000BB">$object</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 notes" id="refsect1-function.spl-object-hash-notes"> <h3 class="title">Notes</h3> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> When an object is destroyed, its hash may be reused for other objects. </p> </p></blockquote> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.spl-classes.html">spl_classes</a></div> <div class="next" style="text-align: right; float: right;"><a href="spl.files.html">File Handling</a></div> <div class="up"><a href="ref.spl.html">SPL Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>