I've just started to use codeigniter and I have a question.
I am using arrays for defining certain values like:
$gender = array ('male','female');
Or:
$maritalStatus = array ('married', 'single', 'divorc开发者_开发百科ed');
I am using these kind of arrays in different views. My question is, is there a chance to put all of these arrays in a configuration file and load it when I need it? Or is there another method to achieve this?
Thanks a lot.
Yes, you can. Just place all your variables in an array, and save that array in a separate config file in system/application/config
.
Then, in your application code, load the config file like so:
$this->config->load($config_file);
Where $config_file
is the name of your config file, without the .php
extension.
精彩评论