Req #15232 [Com]: Need a possibility to compare two references
| From: | datibbaw@php.net | Date: | Tue, 23 Aug 2011 14:19:43 +0000 |
| Subject: | Req #15232 [Com]: Need a possibility to compare two references | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-162853@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=15232&edit=1
ID: 15232
Comment by: datibbaw@php.net
Reported by: flying at dom dot natm dot ru
Summary: Need a possibility to compare two references
Status: Open
Type: Feature/Change Request
Package: Feature/Change Request
Operating System: All
PHP Version: 4.0.6
Block user comment: N
Private report: N
New Comment:
For scalar values, this is impossible. And you probably don't want this either,
because $a and $b might actually point to the same value (e.g. due to compiler
optimization)
For objects you could use the equality operator (===). For example:
$a = new mynumber(5);
$b = new mynumber(5);
echo $a === $b;
Previous Comments:
------------------------------------------------------------------------
[2002-01-26 06:18:25] flying at dom dot natm dot ru
PHP have no possiblity to find, if two references points to the same actual variable, but sometimes
it is necesary.
Short example:
$a = 5;
$b = 5;
$a_ref1 = &$a;
$a_ref2 = &$a;
$b_ref = &$b;
PHP needs a function (or operator) which will return TRUE, when comparing $a_ref1 and $a_ref2, but
FALSE, if comparing $a_ref1 and $b_ref.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=15232&edit=1