PHP 8.1.28 Released!


(PHP 7 >= 7.4.0, PHP 8)

ReflectionReference::getIdGet unique ID of a reference


public ReflectionReference::getId(): string

Returns an ID which is unique for the reference for the lifetime of that reference. This ID can be used to compare references for equality, or to maintain a map of known references.

Liste de paramètres

Cette fonction ne contient aucun paramètre.

Valeurs de retour

Returns a chaîne de caractères of unspecified format.


Exemple #1 Basic ReflectionReference::getId() usage

= 'foo';
$val2 = 'bar';
$arr = [&$val1, &$val2, &$val1];

$rr1 = ReflectionReference::fromArrayElement($arr, 0);
$rr2 = ReflectionReference::fromArrayElement($arr, 1);
$rr3 = ReflectionReference::fromArrayElement($arr, 2);

var_dump($rr1->getId() === $rr2->getId());
var_dump($rr1->getId() === $rr3->getId());

L'exemple ci-dessus va afficher :

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top