Working with Global Variables

Posted on 16th Feb 2014 by admin

hi, I'm not really sure why the following code is returning a "Call to a member function getBanners() on a non-object" error message.

Code:
var $_model;

function display ($tpl=null)
{
$this->_model = &$this->getModel();
global $option,$mainframe, $_model;

$Banners = $_model->getBanners();


$this->assignRef('Banners', $Banners);
parent::dislay($tpl);
}

if I replace "$Banners = $_model->getBanners();" with "$Banners = $this->_model->getBanners();" it works fine, I'm trying to shorten the code though.

Other forums