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

From: Date: Thu, 26 Oct 2000 09:52:04 +0000
Subject: PHP 4.0 Bug #7478: empty() function does not work as expected
Groups: php.dev 
Request: Send a blank email to php-dev+get-36056@lists.php.net to get a copy of this message
From: heiner@bintec.de Operating system: Solaris 2.6 PHP version: 4.0.0 PHP Bug Type: Variables related Bug description: empty() function does not work as expected 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 -- Edit Bug report at: http://bugs.php.net/?id=7478&edit=1

« previous php.dev (#36056) next »