我尝试但无法解决,检查并且在严格标准
上收到错误严格的标准:只有变量才能通过引用传递给......
我做错了什么 - 如何纠正
$this->assignRef('prodDet' , $prodDet);
$this->assignRef('CatName' , $modelNewcar->getCatName($id));
$this->assignRef('nav' , $nav);
$this->assignRef('CatList' , $modelNewcar->loadMainCat($brand,$Carmodel,$minprice,$maxprice,$fuel_type));
$this->assignRef('CatName' , $modelNewcar->getCatName);
parent::display($tpl);
以下是原始代码
function display($tpl = null)
{
$mainframe =JFactory::getApplication();
$option = JRequest::getCmd('option');
$db =JFactory::getDBO();
$user = JFactory::getUser();
// Push a model into the view
$model = $this->getModel();
$modelNewcar = $this->getModel( 'product' );
$id = JRequest::getVar('id','','default','int');
$vid = JRequest::getVar('vid','','default','int');
$prodDet = $modelNewcar->loadProduct($id,$vid);
$this->assignRef('prodDet' , $prodDet);
$this->assignRef('CatName' , $modelNewcar->getCatName($id));
parent::display($tpl);
}
function display($tpl = null)
{
$db =JFactory::getDBO();
$user = JFactory::getUser();
// Push a model into the view
$model =$this->getModel();
$modelNewcar =$this->getModel( 'category' );
$brand = JRequest::getVar('brand','','default','int');
$Carmodel = JRequest::getVar('model','','default','int');
$minprice = JRequest::getVar('minprice','','default','int');
$maxprice = JRequest::getVar('maxprice','','default','int');
$fuel_type = JRequest::getVar('fuel_type','','default','');
$this->assignRef('nav' , $nav);
$this->assignRef('CatList' , $modelNewcar->loadMainCat($brand,$Carmodel,$minprice,$maxprice,$fuel_type));
$this->assignRef('CatName' , $modelNewcar->getCatName);
parent::display($tpl);
}
答案 0 :(得分:2)
这正是错误所说的。 $this->assignRef()
通过引用分配变量。
例如:
$this->assignRef('CatName' , $modelNewcar->getCatName($id));
在这里,您尝试将函数getCatName()
传递给assignRef()
。解决方案是首先将其分配给变量。
$catName = $modelNewcar->getCatName($id);
$this->assignRef('CatName' , $catName);