我想用模块从数据库中获取prestashop category info,我使用sql查询,但如果我试图给foreach数组分配prestashop,请重新运行一个错误代码:Parse error: syntax error, unexpected 'return' (T_RETURN)
这是我的密码

    public function hookDisplayHome()
    {
    $getcategory = Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'category_lang`');
    $cattegoryinfo=array();
    foreach($getcategory as $getcategoryinfo){
        $cattegoryinfo[] = array(
         "name" => $getcategoryinfo['name']
         );
    }
         $this->context->smarty->assign('categories', $cattegoryinfo);
         return $this->display(__FILE__,'views/showcategory.tpl');
}

最佳答案

我测试了你的代码,在这行的“;”后发现了一个特殊字符:

$this->context->smarty->assign('categories', $cattegoryinfo);

删除并重试

10-04 22:55