Search code examples
phpjoomla

Only variable to be assigned by reference for $model and $modelproduct


For this code, its stating that only variable to be assigned by reference for $model and $modelproduct. I tried to look at some other example but could not make out of it.

Can any help on same?

public function display($tpl = null)
    {
        $app  = JFactory::getApplication();
        $user = JFactory::getUser();    
        // Push a model into the view
        $model          = &$this->getModel();
        $modelProduct   = &$this->getModel( 'pages' );
        $MSG="";
        $this->assignRef('MSG'  , $MSG);
        parent::display($tpl);
    }

Solution

  • You use &$this in your code. It means that the result of the function should point to a specific location in memory and that could not be.

    I cannot understand why you would like to do that but if think it is a bad understanding of reference. My solution is to remove & as it is unuseful in that case.