Re: A php bug or?..
| From: | Stuart Dallas | Date: | Mon, 08 Aug 2011 20:45:05 +0000 |
| Subject: | Re: A php bug or?.. | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-314434@lists.php.net to get a copy of this message | ||
On 8 Aug 2011, at 21:41, Andre Polykanine wrote:
> DPB> does it return the number of characters within a string --- instead,
> DPB> as you likely know, you'd use strlen().
>
> For sure. But I'm asking: why it doesn't return 0 if it is not an array?
> Logically: no array - no items!
The manual explains what the function does - you may want to check it out cos it does the same for
all the other functions too.
"Returns the number of elements in var. If var is not an array or an object with implemented
Countable interface, 1 will be returned. There is one exception, if var is NULL, 0 will be
returned."
IOW, if you pass it a variable, that has one element, so it returns 1. An array may have 0 to many
elements, and null, logically, has none. Rocket science this ain't!
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/