spl_object_id()
spl_object_id() — Return the integer object handle for given object.
Built-in function of PHP 8.5. The manual lists it as available in PHP 7 >= 7.2.0, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
This function returns a unique identifier for the object. The object id is unique for the lifetime of the object. Once the object is destroyed, its id may be reused for other objects. This behavior is similar to spl_object_hash().
Signature
spl_object_id(object $object): int
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $object | object | Any object. |
Return value
An integer identifier that is unique for each currently existing object and is always the same for each object.
Example
A runnable snippet:
$id = spl_object_id($object); $storage[$id] = $object;
All PHP 8.5 built-in functions
Reference card built from the PHP manual page spl_object_id() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.