wamp- count(): 参数必须是数组或实现了 Countable 的对象

wamp- count(): Parameter must be an array or an object that implements Countable

我正在使用 symfony 并收到这条消息

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

此消息仅适用于 php 7.2.14,不适用于 php 7.1.26。

我想要一个在服务器上应用的解决方案,例如 phpmyAdmin

我知道有涉及像这样更改代码的解决方案

但我想要一个适用于所有页面的解决方案,所以在服务器端。

提前致谢!

PHP 7.2 现在会在 count() 参数不可数时发出警告。来自 PHP 文档:

Version 7.2.0 : count() will now yield a warning on invalid countable types passed to the array_or_countable parameter.

如果问题来自 Symfony,您应该至少更新到 Symfony 版本 3.4(参见 this issue)。

如果问题出在您的代码上,您应该将代码编辑为仅 count() 数组或类 实现 Countable 接口