当前位置: 首页 > 知识库问答 >
问题:

PHP警告:Count():参数必须是一个数组或一个对象,在C:\\htdocs\my.php[关闭]中实现Countable

蔚琦
2023-03-14

count():参数必须是在C:\htdocs..\components\com\u jcomments\tpl\joomspirit\u theme\tpl\u form.php中实现可计数的数组或对象

$customBBCodes = $this->getVar('comments-form-custombbcodes');
if (count($customBBCodes)) {
    foreach($customBBCodes as $code) {
        if ($code->button_enabled) {
            $k = 'custombbcode' . $code->id;
            $title = trim(JCommentsText::jsEscape($code->button_title));
            $text = empty($code->button_prompt) ? JText::_('BBCODE_HINT_ENTER_TEXT') : JText::_($code->button_prompt);
            $open_tag = $code->button_open_tag;
            $close_tag = $code->button_close_tag;
            $icon = $code->button_image;
            $css = $code->button_css;
        }
    }
}

我在Joomla 3.0应用程序中运行这个脚本,在Apache上使用PHP7.3。

共有1个答案

戎兴言
2023-03-14

必须添加
if(is_array($CustBBCodes)){

都改成

   `$customBBCodes = $this->getVar('comments-form-custombbcodes');
    if(is_array($customBBCodes)){
        if (count($customBBCodes)) {
            foreach($customBBCodes as $code) {
                if ($code->button_enabled) {
                    $k = 'custombbcode' . $code->id;
                    $title = trim(JCommentsText::jsEscape($code->button_title));
                    $text = empty($code->button_prompt) ? JText::_('BBCODE_HINT_ENTER_TEXT') : JText::_($code->button_prompt);
                    $open_tag = $code->button_open_tag;
                    $close_tag = $code->button_close_tag;
                    $icon = $code->button_image;
                    $css = $code->button_css;`                    
 类似资料: