Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php CodeIgniter:自定义配置文件错误似乎不包含有效的配置数组_Php_Arrays_Codeigniter_Routes_Config - Fatal编程技术网

Php CodeIgniter:自定义配置文件错误似乎不包含有效的配置数组

Php CodeIgniter:自定义配置文件错误似乎不包含有效的配置数组,php,arrays,codeigniter,routes,config,Php,Arrays,Codeigniter,Routes,Config,我需要在my route.php中有一个配置文件 require "agent.php"; 这份报告有一些错误 应用程序/config/agent.php文件似乎不包含 有效的配置数组 这是我的agent.php文件的代码 <? $config['agent_route'] = "zhutest1|zhutest2|zhutest3|livwyy|beyoung"; $config['agent_aid_ary'] = array( "zhutest1" => "2", "zh

我需要在my route.php中有一个配置文件

require "agent.php";
这份报告有一些错误

应用程序/config/agent.php文件似乎不包含 有效的配置数组

这是我的agent.php文件的代码

<?

$config['agent_route'] = "zhutest1|zhutest2|zhutest3|livwyy|beyoung";

$config['agent_aid_ary'] = array(
"zhutest1" => "2",
"zhutest2" => "3",
"zhutest3" => "4",
"livwyy" => "9",
"beyoung" => "11",
);

$config['agent_username_ary'] = 
array(
"2" => "zhutest1",
"3" => "zhutest2",
"4" => "zhutest3",
"9" => "livwyy",
"11" => "beyoung",
);


$config['gender']= array ('male','female');

?>


配置数组变量不能使用键值数组吗

您不需要使用require('agent.php')

在codeigniter中,您可以使用

$this->config->load('agent');
然后使用自定义配置数组:-

$this->config->item('agent_username_ary');
确保agent.php位于config文件夹中,并且每个配置键名称都是唯一的

阅读文档了解更多信息