Re: PHP 4.0 Bug #7478 Updated: empty() function does not work as expected

From: Date: Thu, 26 Oct 2000 11:23:00 +0000
Subject: Re: 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-36061@lists.php.net to get a copy of this message
> 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@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 ----- End Included Message -----

« previous php.dev (#36061) next »