== object comparison bug?

From: Date: Wed, 28 Apr 2004 17:25:35 +0000
Subject: == object comparison bug?
Groups: php.internals 
Request: Send a blank email to internals+get-9603@lists.php.net to get a copy of this message
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

« previous php.internals (#9603) next »