PHP 获取 对象唯一id spl_object_hash

// 对象spl_object_hash测试
$object = new stdClass;
$id = spl_object_hash($object);
var_dump($id); // 00000000408de7e4000000006ad86d42
$object->id = 1;
$id = spl_object_hash($object);
var_dump($id); // 00000000408de7e4000000006ad86d42

注意

When an object is destroyed, its hash may be reused for other objects.
当对象被销毁时候,这个哈希id可能被其他对象重用

相关文章

此处评论已关闭