#28219 [Opn->Bgs]: == object comparison produces E_NOTICE

From: Date: Thu, 29 Apr 2004 18:20:55 +0000
Subject: #28219 [Opn->Bgs]: == object comparison produces E_NOTICE
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-59014@lists.php.net to get a copy of this message
ID: 28219 Updated by: derick@php.net Reported By: hans at velum dot net -Status: Open +Status: Bogus Bug Type: Zend Engine 2 problem Operating System: Linux PHP Version: 5.0.0RC2 New Comment: Duplicate of bug #28165. Please search the database before filing a bug. Previous Comments: ------------------------------------------------------------------------ [2004-04-29 18:38:20] hans at velum dot net Description: ------------ I get Notice: Object of class File could not be converted to integer when trying to compare object contents using '==' comparison operator. Comparing the actual reference using === works, but obviously means something different. Reproduce 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"; } Expected result: ---------------- File Object ( [var] => test ) File Object ( [var] => test ) $t1 == $t2 ? YES Actual result: -------------- 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28219&edit=1

« previous php.bugs (#59014) next »