I'd like to define a global object variable that I could use in several of the functions in my controller, Items.
Here's my code that doesn't work:
class Items extends CI_Controller {
private $varname;
function Items(){
parent::__construct();
$this->load->model('items_model');
$folder_id=416;
$this->varname=$this->items_model->getFilesById($folder_id);
}
function index(){
var_dump($this->varname);
}
}
So $this->varname doesn't work as evidenced when I go to the url: localhost/items/index the printed ouput is this:
array(0) { }