• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Global Variable

Hi All,

I am hoping to define a global variable in my controllers that can then be accessed from my Models and core files (e.g. DB_active_rec). I've tried using a constant, which works- but in certain scenarios I need to redefine the value within my controller which a constant doesn't support.

I've also tried defining a global variable in the controller class, but it isn't available in the models/core files.

Any pointers or suggestions would be greatly appreciated.


I use the config class for those cases.

$this->config->set_item('item_name', 'item_value');

After setting an config item anywhere in your application its global accessable.

$item_value = $this->config->item('item_name');


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.