CodeIgniter Forums
config items versus constants, seeking clarification. - 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: config items versus constants, seeking clarification. (/showthread.php?tid=36374)



config items versus constants, seeking clarification. - El Forum - 11-29-2010

[eluser]nuwanda[/eluser]
I'm wondering how others are using config items versus constants.

I understand that configs can be altered dynamically. This essentially means the config set in the config file is a default value and can then be altered temporarily for the duration of the script.

Makes sense.

Are there any other reasons to use config items over constants?

I tend to use constants as they are retrieved with less typing and they stand out more.


config items versus constants, seeking clarification. - El Forum - 11-29-2010

[eluser]skunkbad[/eluser]
I define constants in hooks so that I can use them before config items are set. I use config items when they are specifically related to some library or code, to help keep things organized.


config items versus constants, seeking clarification. - El Forum - 11-30-2010

[eluser]nuwanda[/eluser]
[quote author="skunkbad" date="1291117792"]I define constants in hooks so that I can use them before config items are set. I use config items when they are specifically related to some library or code, to help keep things organized.[/quote]

Just out of interest, what exactly are you using your hooks for?


config items versus constants, seeking clarification. - El Forum - 11-30-2010

[eluser]skunkbad[/eluser]
[quote author="nuwanda" date="1291120844"][quote author="skunkbad" date="1291117792"]I define constants in hooks so that I can use them before config items are set. I use config items when they are specifically related to some library or code, to help keep things organized.[/quote]

Just out of interest, what exactly are you using your hooks for?[/quote]

I have a hook that sets up $_SESSION, and another for a custom error handler. I also have one that sets the X-Powered-By header.