note 95666 added to function.spl-object-hash
| From: | daandottimmeratgmaildotcom at osu1 dot php dot net | Date: | Thu, 14 Jan 2010 15:30:32 +0000 |
| Subject: | note 95666 added to function.spl-object-hash | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-164979@lists.php.net to get a copy of this message | ||
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
----
Server IP: 69.147.83.197
Probable Submitter: 213.93.229.126
----
Manual Page -- http://www.php.net/manual/en/function.spl-object-hash.php
Edit -- https://master.php.net/note/edit/95666
Del: integrated -- https://master.php.net/note/delete/95666/integrated
Del: useless -- https://master.php.net/note/delete/95666/useless
Del: bad code -- https://master.php.net/note/delete/95666/bad+code
Del: spam -- https://master.php.net/note/delete/95666/spam
Del: non-english -- https://master.php.net/note/delete/95666/non-english
Del: in docs -- https://master.php.net/note/delete/95666/in+docs
Del: other reasons-- https://master.php.net/note/delete/95666
Reject -- https://master.php.net/note/reject/95666
Search -- https://master.php.net/manage/user-notes.php