如何加载自定义配置文件,codeigniter? [英] How do I load custom configuration files with codeigniter?

查看:102
本文介绍了如何加载自定义配置文件,codeigniter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用codeigniter和我有一个问题。

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'); 

或者

$maritalStatus = array ('married', 'single', 'divorced');

我使用的这几样在不同的视图阵列。我的问题是,有没有办法把所有这些阵列的配置文件中,当我需要它加载它一个机会?还是有实现这个另一种方法?

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?

非常感谢。

推荐答案

是的,可以。只需将阵列中的所有变量,并保存在一个单独的配置文件数组中系统/应用/配置

Yes, you can. Just place all your variables in an array, and save that array in a separate config file in system/application/config.

然后,在你的应用程序code,加载配置文件像这样:

Then, in your application code, load the config file like so:

$this->config->load($config_file);

其中, $ CONFIG_FILE 是您的配置文件的名称,而不的.php 扩展。

Where $config_file is the name of your config file, without the .php extension.

这篇关于如何加载自定义配置文件,codeigniter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆