Warning: count(): Parameter must be an array or an object that implements Countable快速解决方法

Warning: count(): Parameter must be an array or an object that implements Countable。
解决thinkphp3项目在开发时弹出一个警告Warning: count(): Parameter must be an array or an object that implements Countable。
这说明count()参数必须是一个数组或一个对象,和前面warning: a non-numeric value encountered in line错误类似,都是php7版本引起的。版本更新后,部分方法会变得更加严谨,传递一个无效参数的时候,count()函数抛出warning的警告

From this it seems that the count() parameter must be an array or an object, just set it as an array and try, the original error code line:
count( discountlist), changed to: count ((array) discount_list), changed to: count((array)discountlI S T ) , modified as : C O U n- T ( ( A R & lt R & lt A Y ) discount_list)
Save and clearing cache error disappears.
In this way, it seems that this problem can be adjusted according to the error message. I hope this article can bring you a little help.

Guess you like

Origin blog.csdn.net/u010991531/article/details/105411182