关于使用php的spl_object_hash生成GUID
2014-08-22 13:51
537 查看
转自:http://php.net/manual/zh/function.spl-object-hash.php
Note:
When an object is destroyed, its hash may be reused for other objects.
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; } } ?>
Note:
When an object is destroyed, its hash may be reused for other objects.
相关文章推荐
- PHP SplObjectStorage使用实例
- 关于使用php链接sql数据库生成json数据
- 关于PHP使用GD库生成的验证码无法在别处显示
- PHP SplObjectStorage使用实例
- 关于UUID和GUID,教你如何使用JDK自带的UUID生成主键。
- PHP SplObjectStorage使用实例
- 关于PHP与Sybase数据库的连接与使用
- asp/php下生成GUID
- PHP下生成GUID(已测)(转载)
- 使用PHP快速生成Flash 动画
- 关于zeo作品中生成代码使用方法的说明!
- 使用php 的缓冲区功能和apache的url重写功能实现静态html生成实例
- aix中使用xlc编译生成动态链接库(shared object)(.so)文件的方法
- 关于PHP Pear 安装及使用
- 使用ASP生成 GUID
- 关于Data Access Blok (SqlHelper.cs)使用时出现"对象必须实现 IConvertible/Object must implement IConvertible."异常
- 关于GUID的使用
- 使用PHP 快速生成Flash 动画
- 关于在toj上使用hash_map(回复黄冶)
- 如何使用PHP动态生成饼状图、柱状图和折线图