On Tue, 2007-05-15 at 17:27 +0100, Edward Kay wrote:
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 15 May 2007 16:48
To: php-general@lists.php.net
Subject: [PHP] PHP 5.2 array() == null
Hi people
i was just curios to ask whether
array() == null should always return true. and then why
i'm testing this with php 5.2.2
greetings
dominic letz
According to Table Q.2 at
http://www.php.net/manual/en/types.comparisons.php, array() == NULL will
always return TRUE.
Remember == is a loose comparison. I think this is a result of the
following:
array() == FALSE is TRUE (because it's empty?)
Yes, being empty is why it is equivalent to boolean false. It makes it
simple and self explanatory to do code like the following:
?php
if( $array )
{
// do something since it's not empty
}
else
{
// sorry nothing was found.
}
?
This is preferable to using the count() function since no function
overhead is incurred.
Cheers,
Rob.
--
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`'
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php