[PHP-DEV] Bug #1348: count() can't identify a non-array variable correctly From: mike24 <email protected>
Date: 04/24/99

From: mike24 <email protected>
Operating system: Linux 2.0.36
PHP version: 3.0.7
PHP Bug Type: Misbehaving function
Bug description: count() can't identify a non-array variable correctly

The manual says that count "returns 1 if the variable is not an array." This can produce inaccurate results if the variable is an array, but has only one element.

Temporary Solution:
Don't use count(). Instead use is_array(), isset(), and sizeof().

Solution:
Set integer returned by count() to (-1) when the tested variable is not an array.

--
PHP Development Mailing List   http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe <email protected>
For help: php-dev-help <email protected>