PHP 警告:count(): 参数必须是数组或在 C:\\htdocs\my.php 中实现 Countable 的对象
PHP Warning: count(): Parameter must be an array or an object that implements Countable in C:\\htdocs\my.php
count(): Parameter must be an array or an object that implements Countable in C:\htdocs..\components\com_jcomments\tpl\joomspirit_theme\tpl_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。
必须添加
if(is_array($customBBCodes)){
全部改为
`$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;`
count(): Parameter must be an array or an object that implements Countable in C:\htdocs..\components\com_jcomments\tpl\joomspirit_theme\tpl_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。
必须添加
if(is_array($customBBCodes)){
全部改为
`$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;`