= 5.2.0, PHP 7, PHP 8)spl_object_hash — 返回指定對(duì)象的hash id 說(shuō)明spl_object_hash(object $obj): string本函數(shù)為指定對(duì)象返回一個(gè)唯一標(biāo)識(shí)符。這個(gè)標(biāo)識(shí)符可用于作為保存對(duì)象或區(qū)">

spl_object_hash

(PHP 5 >= 5.2.0, PHP 7, PHP 8)

spl_object_hash 返回指定對(duì)象的hash id

說(shuō)明

spl_object_hash(object $obj): string

本函數(shù)為指定對(duì)象返回一個(gè)唯一標(biāo)識(shí)符。這個(gè)標(biāo)識(shí)符可用于作為保存對(duì)象或區(qū)分不同對(duì)象的hash key。

參數(shù)

object

Any object.

返回值

字符串,對(duì)于每個(gè)對(duì)象它都是唯一的,并且對(duì)同一個(gè)對(duì)象它總是相同。

范例

示例 #1 A spl_object_hash() example

<?php
$id 
spl_object_hash($object);
$storage[$id] = $object;
?>

注釋

注意:

When an object is destroyed, its hash may be reused for other objects.