Bug #1348: count() can't identify a non-array variable correctly

From: Date: Sat, 24 Apr 1999 20:56:31 +0000
Subject: Bug #1348: count() can't identify a non-array variable correctly
Groups: php.dev 
Request: Send a blank email to php-dev+get-5250@lists.php.net to get a copy of this message
From: mike24@bellsouth.net 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@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#5250) next »