Re: Why count() returns no error when string is given ?
| From: | Florian Lemaitre | Date: | Tue, 16 Aug 2011 15:17:48 +0000 |
| Subject: | Re: Why count() returns no error when string is given ? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-314548@lists.php.net to get a copy of this message | ||
Le 16/08/2011 16:50, rsk82@live.com a écrit :
Hello Florian, Tuesday, August 16, 2011, 4:32:39 PM, you wrote:You can see the archive here : http://www.mail-archive.com/php-general@lists.php.net/msg267800.htmlmanual : 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."Yes I know, but I wonder what is the master reason behind this line of doing things ? The fact that something is documented shoudn't make it automatically right. Are there scripts where people are putting strings into count by purpose, not by an accident ? Is this behavior having some grand purpose behind id, or is it just a historical accident for early days of php ? this question has already been discussed 8 days ago in this mailing list.