Re: echo count(false); == 1 ?!
| From: | Jim Lucas | Date: | Wed, 27 Nov 2013 19:41:12 +0000 |
| Subject: | Re: echo count(false); == 1 ?! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-322524@lists.php.net to get a copy of this message | ||
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/