我正在尝试在 codeigniter 3 中加载自定义配置
$this->config->load('test')
Run Code Online (Sandbox Code Playgroud)
test.php 文件在application/config包含以下内容的文件夹中可用。
<?php
$config['item_test']='sample config item';
Run Code Online (Sandbox Code Playgroud)
我会收到以下错误
配置文件 test.php 不存在。
Codeigniter 版本:3.1.0
小智 5
在 application/config 文件夹中创建新的文件名 test.php。
应用程序/配置/test.php
<?php
$config['gender'] = array('Male', 'Female');
?>
Run Code Online (Sandbox Code Playgroud)控制器/文件名.php
class Stackoverflow extends CI_Controller{
function __construct() {
parent::__construct();
$this->config->load('test'); //loading of config file
}
function index(){
print_r($this->config->item('gender')); //Calling of config element.
}
}
Run Code Online (Sandbox Code Playgroud)输出
数组( [0] => 男性 [1] => 女性)
| 归档时间: |
|
| 查看次数: |
5983 次 |
| 最近记录: |