I have a MY_Controller class with this property:
class MY_Controller extends CI_Controller
{
public $_template;
protected $_view;
...
//Some methods here
}
I have the Profille Controller:
class profile extends MY_Controller {
protected $_view = 'consultoria/profile';
public function __construct() {
parent::__construct();
}
public function index() {
$this->_template->build($this->_view);
}
}
The problem is when I try to use parent:: instead of $this on index()
parent::_template->build($this->_view)
The error message:
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in C:\xampp\htdocs\officeprime\application\controllers\consultoria\profile.php on line 18
Why I can’t use parent?
You double colon
::for static, contant properties or methods. Use$this->instead ofparent::. For eaching any of your parent class elements in CI just use$this->