php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28219 == object comparison produces E_NOTICE
Submitted: 2004-04-29 18:38 UTC Modified: 2004-04-29 20:20 UTC
From: hans at velum dot net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.0.0RC2 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: hans at velum dot net
New email:
PHP Version: OS:

 

 [2004-04-29 18:38 UTC] 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 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-29 20:20 UTC] derick@php.net
Duplicate of bug #28165. Please search the database before filing a bug.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 02:01:36 2025 UTC