#34291 [NEW]: reference comparison: $a isIdenticalTo $b
| From: | csaba at alum dot mit dot edu | Date: | Sun, 28 Aug 2005 21:02:52 +0000 |
| Subject: | #34291 [NEW]: reference comparison: $a isIdenticalTo $b | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-84103@lists.php.net to get a copy of this message | ||
From: csaba at alum dot mit dot edu
Operating system:
PHP version: 5.1.0RC1
PHP Bug Type: Feature/Change Request
Bug description: reference comparison: $a isIdenticalTo $b
Description:
------------
I would like to recommend a (boolean) operator:
$ref1 isIdenticalTo $ref2
to compare whether two references are identical.
A main use of this is in tree traversal. For example:
$a = array(7);
$a[] = &$a; // we now have a self reference
print $a[1][1][1][0]; // => 7. All is OK
if ($a==$a[1]) print "same"; // Fails
Both $a==$a[1] and $a===$a[1] will fail because the nesting level is too
deep. This is in agreement with the documentation, which says that values
are tested.
If I could do isIdenticalTo however (one could not use ==== with a
straight face), then by placing the references of subarrays encountered
onto an $aVisited array, I could run through them myself and check with
isIdenticalTo and thus avoid exceeding a nesting level.
An example where this (appropriately) happens is with $GLOBALS, since
$GLOBALS["GLOBALS"] isIdenticalTo $GLOBALS.
Thanks for considering this,
Csaba Gabor from Vienna
--
Edit bug report at http://bugs.php.net/?id=34291&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34291&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34291&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34291&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=34291&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=34291&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=34291&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=34291&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=34291&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=34291&r=support
Expected behavior: http://bugs.php.net/fix.php?id=34291&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=34291&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=34291&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=34291&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34291&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=34291&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=34291&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=34291&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=34291&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=34291&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=34291&r=mysqlcfg