From:             sam at liddicott dot com
Operating system: Linux
PHP version:      4.4.0
PHP Bug Type:     Scripting Engine problem
Bug description:  === is wrong for objects and also stupid

Description:
------------
=== does not compare two objects for identity, it compares the values of
their fields, and recursively at that! It gives wrong answers and in some
cases fails altogether!

Would you believe that === reports two different objects as being the same
object, when they are not references?

Why can't it just check if they have the same storage address, that should
be quick, painless and accurate!

There should be some way to tell when two object references refer to the
same object (apart hack in an extra field and see if it appears in the
other)

Reproduce code:
---------------
<?php

$t->name='t';
$e->name='e';

$t->e=&$e;
$e->t=&$t;

$tt=&$t;

$a->n='n';
$b->n='n';

if ($a===$b) print "Dear me A and B are the same\n";
else print "Of course A and B are different\n";

if ($tt===$t) print "Yes, of course TT and T are the same\n";
else print "No they are not\n";
?>


Expected result:
----------------
"Of course A and B are different"
"Yes, of course TT and T are the same"

Actual result:
--------------
Dear me A and B are the same

Fatal error: Nesting level too deep - recursive dependency? in
/home/sam/projects/reporter/t.php on line 17


-- 
Edit bug report at http://bugs.php.net/?id=35053&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=35053&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=35053&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=35053&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=35053&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=35053&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=35053&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=35053&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=35053&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=35053&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=35053&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=35053&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=35053&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=35053&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=35053&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=35053&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=35053&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=35053&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=35053&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=35053&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=35053&r=mysqlcfg

Reply via email to