php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #15232 Need a possibility to compare two references
Submitted: 2002-01-26 06:18 UTC Modified: 2013-07-12 12:41 UTC
Votes:7
Avg. Score:4.4 ± 0.7
Reproduced:5 of 5 (100.0%)
Same Version:0 (0.0%)
Same OS:4 (80.0%)
From: flying at dom dot natm dot ru Assigned:
Status: No Feedback Package: *General Issues
PHP Version: 4.0.6 OS: All
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: flying at dom dot natm dot ru
New email:
PHP Version: OS:

 

 [2002-01-26 06:18 UTC] 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-23 14:19 UTC] datibbaw@php.net
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;
 [2013-07-12 12:41 UTC] maarten@php.net
-Status: Open +Status: No Feedback -Package: Feature/Change Request +Package: *General Issues
 [2013-07-12 12:41 UTC] maarten@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC