Re: echo count(false); == 1 ?!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/27/2013 10:04 AM, Daevid Vincent wrote:
Really? 1?? I would have expected 0 or false or something other than
positive. *sigh*

$ php -a
php > echo count(false);
1


:-\


So, in the manual [1], it says that count expects either an array [2] or countable object [3] as the first param. If you pass it something other then those two types, why would expect it to behave as if you had passed it an array? I would think one should expect unexpected results if giving unexpected input.

1 http://php.net/count#refsect1-function.count-description
2 http://us3.php.net/manual/en/language.types.array.php
3 http://us3.php.net/manual/en/class.countable.php


--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux