首页 > 解决方案 > Oscommerce如何解决,警告:sizeof(): Parameter must be an array or an object that implement Countable

问题描述

我安装了最新版本的 OSCommerce 框架。在后端类别/产品错误显示如下:

警告:sizeof():参数必须是在 C:\xampp\htdocs\oscommerce\catalog\admin\includes\functions\general.php 第 93 行中实现 Countable 的数组或对象

我尝试使用is_array()count()仍然无法正常工作,下面是代码

    function tep_get_path($current_category_id = '') {
    global $cPath_array;

    if ($current_category_id == '') {
      $cPath_new = implode('_', $cPath_array);
    } else {
      if (sizeof($cPath_array) == 0) {
        $cPath_new = $current_category_id;
      } else {
        $cPath_new = '';
        $last_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where 
        categories_id = '" . (int)$cPath_array[(sizeof($cPath_array)-1)] . "'");
        $last_category = tep_db_fetch_array($last_category_query);

        $current_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where 
        categories_id = '" . (int)$current_category_id . "'");
        $current_category = tep_db_fetch_array($current_category_query);

        if ($last_category['parent_id'] == $current_category['parent_id']) {
          for ($i = 0, $n = sizeof($cPath_array) - 1; $i < $n; $i++) {
            $cPath_new .= '_' . $cPath_array[$i];
          }
        } else {
          for ($i = 0, $n = sizeof($cPath_array); $i < $n; $i++) {
            $cPath_new .= '_' . $cPath_array[$i];
          }
        }

        $cPath_new .= '_' . $current_category_id;

        if (substr($cPath_new, 0, 1) == '_') {
          $cPath_new = substr($cPath_new, 1);
        }
      }
    }

    return 'cPath=' . $cPath_new;
  }

标签: phposcommerce

解决方案


我在文件中添加了下面的代码,只是给出错误的行。

if ($cPath_array == null) {
    $cPath_array = array();
}

它解决了我的错误


推荐阅读