2016-07-28 73 views
0

我試過,但沒有能夠解決,檢查和越來越嚴格的標準嚴格的標準錯誤,無法解決

嚴格的標準錯誤:只有變量應該通過參考...

傳遞

我在做什麼錯 - 如何糾正它

$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); 
} 

回答

2

這正是錯誤所說的。 $this->assignRef()通過引用分配變量。

例如:

$this->assignRef('CatName' , $modelNewcar->getCatName($id)); 

在這裏,您嘗試getCatName()傳遞函數assignRef()。解決方法是先將它分配給一個變量。

$catName = $modelNewcar->getCatName($id); 
$this->assignRef('CatName' , $catName); 

文檔:http://php.net/manual/en/language.references.pass.php