From: hans at velum dot net
Operating system: Linux
PHP version: 5.0.0RC2
PHP Bug Type: Zend Engine 2 problem
Bug description: == object comparison produces E_NOTICE
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 bug report at http://bugs.php.net/?id=28219&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28219&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28219&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=28219&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=28219&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=28219&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=28219&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=28219&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=28219&r=support
Expected behavior: http://bugs.php.net/fix.php?id=28219&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=28219&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=28219&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=28219&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28219&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=28219&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=28219&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=28219&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28219&r=float