【问题标题】:Warning: sizeof(): Parameter must be an array or an object that implements Countable on event maker警告:sizeof():参数必须是在事件制造者上实现 Countable 的数组或对象
【发布时间】:2020-03-23 21:21:39
【问题描述】:

我在 Wordpress 上有一个活动制作者。我收到此错误消息,可能是因为我更新到 PHP 7.2:

Warning: sizeof(): Parameter must be an array or an object that implements Countable in /homepages/7/d544205487/htdocs/wp-content/themes/construction/template-agenda3.php on line 390


Warning: sizeof(): Parameter must be an array or an object that implements Countable in /homepages/7/d544205487/htdocs/wp-content/themes/construction/template-agenda3.php on line 413

第 413 行:

if(sizeof($eventos[$day])>0) echo "</a>";

第 390 行:

if(sizeof($eventos[$day])>0) echo "<a href='#openModal$day' style='text-decoration:none;'>";

【问题讨论】:

    标签: php wordpress


    【解决方案1】:

    在 PHP 7.2 中 sizeof 参数必须是数组或对象

    第 413 行:

    if(is_array($eventos[$day]) && sizeof($eventos[$day]) > 0) echo "</a>";
    

    第 390 行:

    if(is_array($eventos[$day]) && sizeof($eventos[$day])>0) echo "<a href='#openModal$day' style='text-decoration:none;'>";
    

    【讨论】:

      【解决方案2】:

      我了解您想要的具体内容。但您可以解决以下问题:

      更新插件新版本。如果插件不支持,那么你可以修复代码:

      if( is_array($eventos[$day]) && sizeof($eventos[$day])>0) echo "</a>"; 
      
      if(is_array($eventos[$day]) && sizeof($eventos[$day])>0) echo "<a href='#openModal$day' style='text-decoration:none;'>"
      

      或者,用方法count()替换

      【讨论】:

        猜你喜欢
        • 2019-01-27
        • 2018-09-05
        • 2019-06-02
        • 2020-05-28
        • 2018-12-19
        • 1970-01-01
        • 2019-08-15
        • 2020-01-18
        • 2018-09-10
        相关资源
        最近更新 更多