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

> 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().

I'm definitively not looking for isset(), and know what it is doing.

The basic fact is, that I would like to be able
to get three kind of information for a variable:
 
     1. Does a variable exist? -> isset()
     2. Is the variable empty? -> empty ()
     3. Has the variable's content a truth value? -> ($var)
 
The second case does not work as expected.

---------------------------------------------------------------------------

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

----- End Included Message -----

-- 
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>