Hi all,
I have stumbled across something odd related to classes, instances and
NULL in PHP 4. Apparently, an instance of a class that doesn't contain
any variables is always equal to NULL.
class MyClass {
function anyFunction() {
...
}
}
$c = new MyClass();
if ($c == null) {
print "is \$c really null?";
}
`is_null($c)' however, returns `false', as one would expect.
As soon as the class contains a variable, the `$c == null' comparison
returns false.
Is there any logical reason why the comparison with the `==' operator
returns `true'? I don't know about the internals of PHP, but I think
this might be related to implementation details (e.g. instances of
classes being associative arrays). However, from an OOP point of view
this behaviour seems rather weird.
I may not be the first to notice this. I couldn't find anything in the
mailing list, if there has already been a discussion about this, just
point me to the right direction.
Thanks
Oliver
pgpCMvNTB17si.pgp
Description: PGP signature