Bug #15103 Updated: object without any data members equals to false
| From: | hholzgra@php.net | Date: | Fri, 18 Jan 2002 16:42:15 +0000 |
| Subject: | Bug #15103 Updated: object without any data members equals to false | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-77449@lists.php.net to get a copy of this message | ||
ID: 15103
Updated by: hholzgra
Reported By: phpclub@digiways.com
Old Status: Open
Status: Closed
Bug Type: Class/Object related
Operating System: any
PHP Version: 4.1.1
New Comment:
the same is true for empty arrays,
"$something == false" is equivalent to
"empty($something)"
Previous Comments:
------------------------------------------------------------------------
[2002-01-18 11:25:17] phpclub@digiways.com
The code
<?
class A { function foo() {} }
$a = new A;
var_dump($a);
if ($a == false) echo "hahaha";
?>
outputs
"object(a)(0) { } hahaha"
So, for some strange reason PHP thinks that object without data members
is "false". Of course, if we replace "==" with "===", it all works
fine, but that is still a bug.
This problem exists in all existing PHP versions on all platforms.
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=15103&edit=1