|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-01-13 13:01 UTC] jani@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 18:00:01 2025 UTC |
Description: ------------ At the moment, you can't do things like: $GLOBALS === $GLOBALS; or $a = array('a' => &$a); $a === $a['a']; both causes fatal error claiming too deep nesting level. I find it rather strange that you can use references, but you can't test if something is referencing the same thing or not... It would be nice to have some ==== or is_same(&$a,&$b) function which would just do a lookup in the symbol table and if the two variables referencing the same thing it would return true, false otherwise. Reproduce code: --------------- $a = is_same($GLOBALS,$GLOBALS); $x = array('x' => &$x); $b = is_same($x, $x['x']); $x1 = array('c' => &$x1); $x2 = array('c' => &$x2); //same layout, but not the same variable; $c = is_same($x1,$x2); $y1 = "test"; $y2 = $y1; /* plain assignement, maybe same till y1 or y2 not changed, but is_same() shouldn't get affected by optimization behaviour */ $d = is_same($y1,$y2); $z1 = "test2"; $z2 = &$z1; //or $z2 =& $z1; $e = is_same($z1,$z2); Expected result: ---------------- $a === true; $b === true; $c === false; $d === false; $e === true; Actual result: -------------- No way to do this ATM (AFAIK). But please tell me if i didn't read the documentation properly...