Re: Updating legacy code ...

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

 



On 04/03/2019 16:59, Jonesy via php-general wrote:
On Mon, 4 Mar 2019 15:55:30 +0000, Lester Caine wrote:
On 04/03/2019 15:18, Aziz Saleh wrote:
http://php.net/manual/en/function.count.php

   Returns the number of elements in array_or_countable. When the
parameter is neither an array nor an object with implemented Countable
interface, 1 will be returned. There is one exception, if
array_or_countable is NULL, 0 will be returned.

If the item is null, it should indeed return 0.
Except since 7.2.0 it issues a warning as well!
Have to do
echo count((array)$item);
to shut it up ...
Isn't it just:  	 @count($item) 	 ???

We are told that '@' will be dropped at some point? But perhaps it IS the right solution to fix what simply looks like a mistake anyway.

What I AM trying to establish is just what is the 'correct' way to do these things since it is obvious that the methods used for 20+ years are no longer acceptable? @ may work as a fix today, but for PHP8?

Although I'm tempted to nail down PHP7.2 in much the same way I used PHP5.2 for over 10 years and by then I'm well into retirement and can leave it to someone else to do the next re-write :) So perhaps 'count(' -> '@count(' may be the correct solution. The feedback on the Smarty forums suggest simply rolling back to 7.1!

--
Lester Caine - G8HFL
-----------------------------
Contact - https://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - https://lsces.co.uk
EnquirySolve - https://enquirysolve.com/
Model Engineers Digital Workshop - https://medw.co.uk
Rainbow Digital Media - https://rainbowdigitalmedia.co.uk



[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