开发者

How do I load custom configuration files with codeigniter?

开发者 https://www.devze.com 2023-01-05 17:55 出处:网络
I\'ve just started to use codeigniter and I have a question. I am using arrays for defining certain values like:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消