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

#1
[eluser]jon74[/eluser]
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.

Thanks

#2
[eluser]alexwenzel[/eluser]
I use the config class for those cases.

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

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

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

http://ellislab.com/codeigniter/user-gui...onfig.html


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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