Re: PHP 4.0 Bug #4614: Empty strings are also considered as NULL
| From: | Zeev Suraski | Date: | Fri, 26 May 2000 14:25:53 +0000 |
| Subject: | Re: PHP 4.0 Bug #4614: Empty strings are also considered as NULL | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-19508@lists.php.net to get a copy of this message | ||
In PHP 3.0, there is no NULL. NULL is just a bad way to write "NULL", and
thus, "" != "NULL".
In PHP 4.0, NULL has a special value, similar to the SQL NULL. Still,
with auto type conversion, NULL==0. As Andrei said, if you want to
compare with NULL, you would usually want to use ===, which is an equality
operator that does not do type conversions.
Zeev
On 26 May 2000 stephane.legrand@bigfoot.com wrote:
> From: stephane.legrand@bigfoot.com
> Operating system: FreeBSD
> PHP version: 4.0.0 Release
> PHP Bug Type: Other
> Bug description: Empty strings are also considered as NULL
>
> <?
> $test = "";
> if ($test == NULL) {
> print("test is NULL <br>\n");
> }
> ?>
>
> With PHP4, this code displays "test is NULL".
> With PHP3, this code displays nothing.
>
> - it seems to me that PHP3 has a far more logical behaviour.
> - i think it can be a big incompatibility problem between PHP3 and PHP4.
>
> So, is it a bug or a feature ? And is there a way to force PHP4 to act like PHP3 in this
> particular case ?
>
> Thank you.
> Stephane Legrand.
>
>
>
--
Zeev Suraski <zeev@zend.com>
http://www.zend.com/