PHP 4.0 Bug #8163: The string "0" tests true as empty()

From: Date: Fri, 08 Dec 2000 10:24:52 +0000
Subject: PHP 4.0 Bug #8163: The string "0" tests true as empty()
Groups: php.dev 
Request: Send a blank email to php-dev+get-40541@lists.php.net to get a copy of this message
From: juhl@eisenstein.dk Operating system: Linux (and probably others) PHP version: 4.0.3pl1 PHP Bug Type: Scripting Engine problem Bug description: The string "0" tests true as empty() The script below produce the following oputput: a is of type string b is of type string b is empty I believe the 'b is empty' part is wrong, as the variable actually contains a string that is one char long and as such is not empty. <?php $a = '1'; $b = '0'; echo 'a is of type '.gettype($a).'<br>'; echo 'b is of type '.gettype($b).'<br>'; if (empty($a)) { echo 'a is empty<br>'; } if (empty($b)) { echo 'b is empty<br>'; } ?> Best regards, Jesper Juhl -- Edit Bug report at: http://bugs.php.net/?id=8163&edit=1

« previous php.dev (#40541) next »