I try to create new stdClass but still nothing and this code make an error: Warning: Creating default object from empty value.
function __construct($params) {
parent::__construct($params);
//$this -> view -> controller = null;
$this -> view -> controller = new stdClass(); // <-- HERE IS ERROR
$this -> view -> controller = 'Index';
require_once 'models/_index_model.php';
$this -> model = new Index_model();
$action = 'News';
if(isset($params[1])){ $action = ucfirst($params[1]); }
$this->date = 'Today';
if(isset($params[2])) $this->date = ucfirst($params[2]);
$this->$action($this->date);
}
The problem is, that there's no value for the variable $view
I'm not sure what you'd like to achieve, but the code should work if you implement it like in the following example:
function __construct($params) {
parent::__construct($params);
$this -> view = new stdClass(); // create a new stdClass object
$this -> view -> controller = 'Index'; // assign the controller value
// ... and so on
}
So the main problem here, is that the variable $view
was not declared, or its value is not an object.
Feel free to ask in the comment section if there are more questions