note 104508 deleted from function.spl-object-hash by danbrown

From: Date: Mon, 20 Jun 2011 15:36:18 +0000
Subject: note 104508 deleted from function.spl-object-hash by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-180782@lists.php.net to get a copy of this message
Note Submitter: netmosfera at gmail dot com ---- if you don't like how spl_object_hash works, here is an alternative class AAA { protected $hash; function __construct() { $this->hash = function() { static $hashStr; if(!isset($hashStr)) $hashStr = uniqid(get_called_class(), true); return $hashStr; }; } function getHashCode() { $f = $this->hash; return $f(); } } i used a closure and a static variabile because storing hashcode as class field the == operator would not worked like expected HTH

« previous php.notes (#180782) next »