PHP提示:Warning: count():Parameter must be an array or an object that implements Countable错误的原因及解决办法

admin 阅读:85 2024-03-04

报错信息:Warning: count(): Parameter must be an array or an object that implements Countable

错误原因:PHP7.2版本之后,count()函数的参数无效时会抛出该warning警告。

解决办法

1.简单粗暴的方法降级PHP版本。

2.如果是使用laravel框架报错的话,composer update一下就可以修复了。

3.检查count函数的参数,对参数做好校验判断预防报错。

声明

1、部分文章来源于网络,仅作为参考。
2、如果网站中图片和文字侵犯了您的版权,请联系1943759704@qq.com处理!