note 95666 deleted from function.spl-object-hash by googleguy
| From: | googleguy@php.net | Date: | Mon, 08 Oct 2012 04:12:23 +0000 |
| Subject: | note 95666 deleted from function.spl-object-hash by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191179@lists.php.net to get a copy of this message | ||
Note Submitter: daan dot timmer at gmail dot com
----
To add to markus dot albe at mailinator dot com comment.
The unique identifiers of destroyed objects can and will be reused.
<?php
class Foo{
private static $test = 0;
public function __construct(){
self::$test++;
}
}
$foo1 = new Foo();
$foo2 = new Foo();
$foo3 = new Foo();
//new unique identifier
echo spl_object_hash($foo1)."<br />\n";
//new unique identifier
echo spl_object_hash($foo2)."<br />\n";
//new unique identifier
echo spl_object_hash($foo3)."<br />\n";
$foo1 = new Foo();
//new unique identifier because, when we created Foo, foo1 still existed
echo spl_object_hash($foo1)."<br />\n";
$foo1 = new Foo();
//same identifier as the first $foo1 because it was destroyed,
//thus released the identifier
echo spl_object_hash($foo1)."<br />\n";
?>
This will output something like:
000000007ec3fcb5000000003f984510
000000007ec3fcb6000000003f984510
000000007ec3fcb7000000003f984510
000000007ec3fcb0000000003f984510
000000007ec3fcb5000000003f984510