Re: Why count() returns no error when string is given ?

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

 



Le 16/08/2011 16:32, Florian Lemaitre a écrit :
Le 16/08/2011 16:29, rsk82@xxxxxxxx a écrit :
For example when I do:

   strlen(array(1,2,3));

php shows: Warning: strlen() expects parameter 1 to be string, array
given in...

but when I do:

   count('string');

It simply returns 1 like nothing happened. I would expect such
behavior if I write:

   count((array)'string')

but otherwise such behavior is very misleading and inconsistent.


manual : function.count.php

"Returns the number of elements in/var/. If/var/is not an array or an object with implementedCountable <http://www.php.net/manual/en/class.countable.php>interface,/1/will be returned. There is one exception, if/var/is*NULL*,/0/will be returned."

Oups...
"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."


--
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