note 87422 added to function.spl-object-hash
| From: | RafaelM dot Salvioni at osu1 dot php dot net | Date: | Thu, 04 Dec 2008 19:01:26 +0000 |
| Subject: | note 87422 added to function.spl-object-hash | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-147637@lists.php.net to get a copy of this message | ||
The follow function is a implementation of the PHP´s function spl_object_hash(), unavailable in
versions less 5.2.0.
But, the algorithm of this function is different of the original PHP´s function.
(Sorry... my english is very bad...)
<?php
if (!function_exists('spl_object_hash')) {
/**
* Returns the hash of the unique identifier for the object.
*
* @param object $object Object
* @author Rafael M. Salvioni
* @return string
*/
function spl_object_hash($object)
{
if (is_object($object)) {
ob_start(); var_dump($object); $dump = ob_get_contents(); ob_end_clean();
if (preg_match('/^object\(([a-z0-9_]+)\)\#(\d)+/i', $dump, $match)) {
return md5($match[1] . $match[2]);
}
}
trigger_error(__FUNCTION__ . "() expects parameter 1 to be object",
E_USER_WARNING);
return null;
}
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 201.28.8.198
----
Manual Page -- http://www.php.net/manual/en/function.spl-object-hash.php
Edit -- https://master.php.net/note/edit/87422
Del: integrated -- https://master.php.net/note/delete/87422/integrated
Del: useless -- https://master.php.net/note/delete/87422/useless
Del: bad code -- https://master.php.net/note/delete/87422/bad+code
Del: spam -- https://master.php.net/note/delete/87422/spam
Del: non-english -- https://master.php.net/note/delete/87422/non-english
Del: in docs -- https://master.php.net/note/delete/87422/in+docs
Del: other reasons-- https://master.php.net/note/delete/87422
Reject -- https://master.php.net/note/reject/87422
Search -- https://master.php.net/manage/user-notes.php