Welcome Guest, Not a member yet? Register   Sign In
defining constants in a config file?

(12-14-2015, 06:44 PM)sneakyimp Wrote: When would one ever want to change the values in a config file? Yes, you are certainly correct that constants cannot be changed during the execution of a script, but given the nature of these configuration files and the values they contain, I don't see this ever happening in practice.

You have a multi language website, I think you would then want to change the language setting in your config file to match your visitors chosen language.

Agreed, for most config settings the need to change them on the fly is small. But making this kind of assumption could get you in to trouble down the road.

If you are worried about misspelling and bugs, maybe you could do a combination. Use constants for the names of your config items instead of the values.

PHP Code:
$config['my_config_item'] = 'my_config_value';

$value $this->config->item(ABCD_MY_CONSTANT); 

Messages In This Thread
RE: defining constants in a config file? - by Martin7483 - 12-15-2015, 02:00 AM

Theme © iAndrew 2016 - Forum software by © MyBB