== object comparison bug?

php.internals

Hans Lellelid

22 years ago
I'm using PHP5.0.0RC2. I saw that there was a similar question posted, but apparently that issue had already been fixed. ---code---------------------------- class File { public $var; function __construct($val) { $this->var = $val; } } $t1 = new File("test"); $t2 = new File("test"); print_r($t1); print_r($t2); print "\$t1 == \$t2 ?"; if ($t1 == $t2) { print "YES\n"; } else { print "NO\n"; } ---output---------------------------- File Object ( [var] => test ) File Object ( [var] => test ) $t1 == $t2 ? Notice: Object of class File could not be converted to integer in /var/www/apps/ddi/test.php on line 18 Notice: Object of class File could not be converted to integer in /var/www/apps/ddi/test.php on line 18 YES I don't know why anything is being coverted to an _integer_. Is this intended behavior? If so, how do I do a PHP4-style object contents comparison? Using === doesn't produce any notice, but also means something very different of course. Hans

Andi Gutmans

22 years ago
Thanks for the detailed report. This should be fixed in the latest CVS. Andi At 01:25 PM 4/28/2004 -0400, Hans Lellelid wrote: