【问题标题】:PHP Warning: count(): Parameter must be an array or an object that implements Countable inPHP 警告:count(): 参数必须是数组或实现 Countable 的对象
【发布时间】:2019-08-15 07:59:41
【问题描述】:

PHP 警告:count():参数必须是数组或对象,在 /opt/lampp/htdocs/deingreidcht/typo3conf/ext/toctoc_cmets/pi1/class.toctoc_cmets_pi1.php 中实现 Countable 如何解决这个问题

这是我的代码,我已经申请了条件,

if (count($rowsrf)== 0) {

【问题讨论】:

  • 提供有关$rowsrf 是什么的更多信息。目前它无法解决。我只能说$rowsrf 既不是数组也不是实现Countable 的对象.....另外请使用\count 而不是count=== 而不是==count 将返回一个整数!
  • $rowsrf 可能是一个对象 () 并且你不能像你提到的那样算这个。您必须将其解析为标准数组。希望这是有道理的。你的代码应该是if (count((array)$rowsrf)== 0) {

标签: typo3 php-7.2


【解决方案1】:

你可以错字3标准方法 例如在你的控制器中

$this->yourextRepository->findAll()->count();

希望对您有所帮助!

【讨论】:

    猜你喜欢
    • 2018-12-19
    • 1970-01-01
    • 2018-09-10
    • 2020-01-18
    • 2019-06-20
    • 2019-10-18
    • 2019-01-06
    • 2020-01-27
    • 2020-01-26
    相关资源
    最近更新 更多