count():参数必须是实现Countable的数组或对象 [英] count(): Parameter must be an array or an object that implements Countable

查看:405
本文介绍了count():参数必须是实现Countable的数组或对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正面临一个奇怪的案件.我在生产环境中遇到错误,而在开发环境中却无法正常工作.

I'm facing strange case. I face an error in production env not while in dev it's working fine.

发展: Laravel 5.4.28 PHP 7.0.13 MYSQL 5.7.17

Development: Laravel 5.4.28 PHP 7.0.13 MYSQL 5.7.17

生产: Laravel 5.4.28 PHP 7.2.1 MYSQL 5.7.20

Production: Laravel 5.4.28 PHP 7.2.1 MYSQL 5.7.20

在实现代码中.我用过:

In implementation code. I used:

namespace App;
use Illuminate\Support\Facades\Storage;
use Laravel\Scout\Searchable;
use Illuminate\Database\Eloquent\Model;

class Artwork extends Model
{
  use Searchable;

在开发中,它可以正常工作.但是在生产中,它给了我这个错误: count():参数必须是实现Countable的数组或对象 在Builder.php中(第936行)

In development it works fine. But in production it gives me this error: count(): Parameter must be an array or an object that implements Countable in Builder.php (line 936)

如您在此图片中所见:

任何主意这背后的原因是什么?以及如何解决?

Any idea what is the reason behind this? and how to fix?

推荐答案

/将此代码放在路由文件的开头,即可正常工作/

if(version_compare(PHP_VERSION, '7.2.0', '>=')) {
    error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
}

这篇关于count():参数必须是实现Countable的数组或对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆