I added some variables to the bottom of the “CI_Controller” class like so:
$data['foo'] = 'bar';
$data['animal'] = 'dog';
$data['justin_beiber'] = 'terrible';
Since I want these variables to be accessible on ALL my controllers and since all the controllers extends this CI_Controller, I figured this would work:
echo $data['foo'];
die();
I put this in a controller that extends CI_Controller. But it doesn’t output anything. How to get this to work?
Maybe proper use of the config options would help you.
http://codeigniter.com/user_guide/libraries/config.html
You can call a config item from anywhere in the CI structure.
and as per why your variables aren’t echoing: You can set protected vars in a class to make them visible by inheritance, but I don’t think that’s the best way to go about doing this. At least not without knowing why you want $data[‘foo’] available everywhere without the use of a helper.