PHP 4.0 Bug #7478 Updated: empty() function does not work as expected
| From: | joey@php.net | Date: | Thu, 26 Oct 2000 10:42:58 +0000 |
| Subject: | PHP 4.0 Bug #7478 Updated: empty() function does not work as expected | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-36057@lists.php.net to get a copy of this message | ||
ID: 7478
Updated by: joey
Reported By: heiner@bintec.de
Status: Closed
Bug Type: Variables related
Assigned To:
Comments:
To be more precise, empty() covers the following:
if ( (! isset($var)) && (! $var) )
This is what empty is made to do. You are probably looking
for isset().
Previous Comments:
---------------------------------------------------------------------------
[2000-10-26 05:52:04] heiner@bintec.de
The following code fragment terminates the script:
$id = "0";
if ( empty ($id) ) {
die ("FATAL: need unique ID number");
}
I would have expected, that
empty ("0")
is always FALSE, because a string containing the character "0" is
definitively not empty [I know that empty() expects a variable, not a constant
as argument].
The expression
if ( empty($var) ) ...
seems to be identical to
if ( !$var ) ...
I strongly feel that empty() should not consider a string with a "0" content
as empty. This functionality is already covered with "if ( !$var)".
Heiner Steven
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=7478