Oliver Hitz wrote:
> Thank you. I know there is a `===' operator, but to me this doesn't
> make sense either.
>
>   class A { }
>   class B { var $x; }
>
> It is logical that an instance of `A' is not identical to null.
> However, why is an instance of `A' equal (`==' operator) to null, an
> instance of `B' not? Do objects automatically evaluate to their
> associative array representation? Is this intended behaviour?

There are four different types that PHP could be casting the object and null to that
would result in them being equal, namely boolean, integer, float, and array.  It's
definitely not casting them to string or object.  My guess is the behavior is not
intentional since the documentation for the "NULL" type says that a variable is
equal to null only if it has had the "null" constant assigned to it, it has not had
a value assigned to it at all, or it has been unset().  You'd probably get more
definitive answers on the internals list.  Personally I consider the behavior a bug,
so I'd probably file a bug report on it, although I wouldn't expect it to be given a
high priority. :)


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to