| 状态 | 草稿 |
|---|---|
| Todo | elaborate on load(), include_paths() |
| 官方最后更新时间 | 2008/08/11 11:23 |
配置文件必须放在 config 文件夹下面,这个文件可以放在 system,application 或者模块 module 目录下面。Application 高于 system 目录(即目录下的配置参数可以覆盖 system 目录下同样配置参数)。Modules 高于 system 但低于 application文件。
配置文件的格式必须是下面的形式:
$config = array ( 'language' => 'en_US', 'timezone' => '' );
Config::item($key, $slash = FALSE, $required = TRUE) 可以检索配置项并返回一个字符串,数组或布尔型。 $slash will force a forward slash at the end of the item. $required determines whether an item is required or not.
Config::item('locale.language'); //returns the language from the **locale.php** file and returns the config['language'] item.
For setting configuration items in realtime you must enable this setting in the config.php file. (core.allow_config_set)
Config::set($key, $value) sets a configuration item, returns TRUE on success or FALSE when it didn't succeed.
Config::set('locale.language','nl_NL');
Note:
Config::include_paths($process= FALSE) gets the include paths and returns an array. First in the array is the application path, last will be the system path, other items will be include paths set in the configuration item 'core.include_paths'. $process, if true, will reprocess the include_paths.
Config::include_paths();
Config::load($name, $required = TRUE) loads a configuration file. Config::item() loads them as well if they're not already loaded and retrieves the items straightaway.
Config::load('locale');