PHP提示:Warning: count():Parameter must be an array or an object that implements Countable

PHP与SEO 思享 171浏览
摘要:
错误原因:PHP7.2以后,count()函数的参数无效时会抛出warning警告。

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

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

php

解决办法

  1. 简单粗暴的方法降级PHP版本。
  2. 如果是使用laravel框架报错的话,composer update一下就可以修复了。
  3. 检查count函数的参数,对参数做好校验判断预防报错。

我比较暴力,直接将参数转化为数组再使用  如:count(a),改为:count((array)a)

推荐阅读

PHP7.4 报错:Deprecated Functionality: implode(): Passing glue string after array is deprecated.

PHP7.4运行项目报错:Deprecated Functionality: implode(): Passing glue string after array is deprecated。只需交换 implode() 函数的两个参数!...

百度自动推送php实现代码

我们知道主动推送有助于搜索引擎抓取和收录网站内容,wordpress或者主流CMS其实已经集成了推送功能。但是如果我们要定期归还,而不是只在发布的时候推一次。这个功能可以通过结合PHP和Pagoda Panel的预定任务来实现。$api = '百度站......

PHP报错Warning:file_get_contents():SSL operation failed with code 1

今天用在线界面验证百度真假蜘蛛,发现报道有误。错误提示显示SSL操作失败,代码为1。我在网上找到了解决方案,分享给大家参考。警告:file_get_contents():无法在/xxx/xxx.php的第31行启用加密。ip=220.181.108.......