CodeIgniter Forums
Constants versus config items - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Constants versus config items (/showthread.php?tid=35749)



Constants versus config items - El Forum - 11-10-2010

[eluser]nuwanda[/eluser]
I just advised someone to use config/constants for global data as opposed to loading a config item as needed.

So, in CI, what's the difference? If I need global settings is using a constant the solution to discretely loading a config item?


Constants versus config items - El Forum - 11-10-2010

[eluser]bretticus[/eluser]
It's the same rule for any PHP coding (and many other languages.) If you anticipate the values ever changing during script execution ($config['base_url'], database config, etc.) use $config. If the value will only ever be set once, define it as a constant instead.