[PHP-DEV] PHP 4.0 Bug #7478 Updated: empty() function does not work as expected From: joey <email protected>
Date: 10/26/00

ID: 7478
Updated by: joey
Reported By: heiner <email protected>
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 <email protected>
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

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>