Re: toString() and Object #ID

From: Date: Wed, 04 Jul 2007 19:23:38 +0000
Subject: Re: toString() and Object #ID
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-30451@lists.php.net to get a copy of this message
Not quite. It creates a hash of an object, so two objects with the same data yield the same hashes: var_dump(spl_object_hash(new stdClass()), spl_object_hash(new stdClass()));
here's the code of spl_object_hash: len = spprintf(&hash, 0, "%p:%d", Z_OBJ_HT_P(obj), Z_OBJ_HANDLE_P(obj)); md5str[0] = '\0'; PHP_MD5Init(&context); PHP_MD5Update(&context, (unsigned char*)hash, len); PHP_MD5Final(digest, &context); make_digest(md5str, digest); RETVAL_STRING(md5str, 1); See any mention of object data? It's not there. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com

« previous php.internals (#30451) next »