note 123669 added to function.count
| From: | lucasfsmartins at gmail dot com | Date: | Thu, 07 Mar 2019 23:26:35 +0000 |
| Subject: | note 123669 added to function.count | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-210337@lists.php.net to get a copy of this message | ||
If you are on PHP 7.2+, you need to be aware of "Changelog" and use something like this:
<?php
$countFruits = is_array($countFruits) || $countFruits instanceof Countable ? count($countFruits) :
0;
?>
You can organize your code to ensure that the variable is an array, or you can extend the Countable
so that you don't have to do this check.
----
Server IP: 208.43.231.9
Probable Submitter: 82.199.157.34 (proxied: 189.100.152.244)
----
Manual Page -- http://php.net/manual/en/function.count.php
Edit -- https://master.php.net/note/edit/123669
Del: integrated -- https://master.php.net/note/delete/123669/integrated
Del: useless -- https://master.php.net/note/delete/123669/useless
Del: bad code -- https://master.php.net/note/delete/123669/bad+code
Del: spam -- https://master.php.net/note/delete/123669/spam
Del: non-english -- https://master.php.net/note/delete/123669/non-english
Del: in docs -- https://master.php.net/note/delete/123669/in+docs
Del: other reasons-- https://master.php.net/note/delete/123669
Reject -- https://master.php.net/note/reject/123669
Search -- https://master.php.net/manage/user-notes.php