Re: Updating legacy code ...
| From: | Christoph M. Becker | Date: | Mon, 04 Mar 2019 14:23:45 +0000 |
| Subject: | Re: Updating legacy code ... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-326725@lists.php.net to get a copy of this message | ||
On 04.03.2019 at 14:58, Lester Caine wrote:
> The one that is causing the most agro is complaints about using 'count'
> especially when they are being thrown in the cached templates used by
> Smarty and other elements of the framework. IS it now required that
> there is a separate check of the item being counted exists where
> previously it simply returned '0'? Throwing (array) in front of each
> just seems totally wrong, but the whole framework runs on the principle
> that an element is created when there is one or more values, and there
> being zero of those elements is flagged by it's absence in the bigger
> associative array. I've yet to work out just how Smarty is handling this
> problem and hacking the cache to add (array) quietens down the
> complaints ... but what is the correct way of handling this?
If I want to know whether my purse is *empty*, I don't have to *count*
the coins. So, use
!empty($item) instead of count($item).
--
Christoph M. Becker