CodeIgniter Forums
constant variables accessable everywhere - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: constant variables accessable everywhere (/thread-26781.html)



constant variables accessable everywhere - El Forum - 01-22-2010

[eluser]pdxbenjamin[/eluser]
Is there a place I can put a "config" file that holds a variables like time and client ID, so that every controller and function in the class has access to?

The project I'm working on is time sensitive and a global time must be the same across the site, and to make my life easier I wanted to create a global config area and not set the time in each function in every controller.


Thanks,


constant variables accessable everywhere - El Forum - 01-22-2010

[eluser]brandon.cordell[/eluser]
constant variable is kind of an oxy moron hehe :-P

application/constants.php holds pre-defined constants. Why not put your constants in there?

You can also create another php file in the aforementioned application/config directory. Then in your application/config/autoload.php you add your config file name to the $autoload['config'] array.

Code:
$autoload['config'] = array('config, another_config');
Use the name of your config file without the .php file extension.


constant variables accessable everywhere - El Forum - 01-22-2010

[eluser]brandon.cordell[/eluser]
-deleted duplicate post-


constant variables accessable everywhere - El Forum - 01-22-2010

[eluser]pdxbenjamin[/eluser]
Thank you I didn't know about the constants.php file.