|
比方说我要引入网站的配置文件cache_category_helper.php, 因为各个地方都要用到,所有准备autoload加载, 此文件放在application/helpers下,文件内容如下,就是个数组
$category = array (
0 =>
array (
'cate_name' => 'cn Leawo DVD23GP',
'setup_filename' => 'ddd',
),
1 =>
array (
'cate_name' => 'cn Leawo DVD23GP',
'setup_filename' => '',
),
2 =>
array (
'cate_name' => 'cn Leawo DVD2AVI',
'setup_filename' => '',
),
3 =>
array (
'cate_name' => 'cn Leawo DVD2iPhone',
'setup_filename' => '',
),
);
$this->load->helper('cache_category');
print_r($category);
报错:Message: Undefined variable: category
我直接引入该文件
include APPPATH. 'helpers/cache_category_helper.php';
print_r($category);
没有问题
把上面的数组装成一个函数
function category(){
$category = array (
0 =>
array (
'cate_name' => 'cn Leawo DVD23GP',
'setup_filename' => 'ddd',
),
1 =>
array (
'cate_name' => 'cn Leawo DVD23GP',
'setup_filename' => '',
),
2 =>
array (
'cate_name' => 'cn Leawo DVD2AVI',
'setup_filename' => '',
),
3 =>
array (
'cate_name' => 'cn Leawo DVD2iPhone',
'setup_filename' => '',
),
);
return $category;
}
$this->load->helper('cache_category');
print_r($category);
没有问题
$this->load->heper();也是include 为何和直接的incldue 不一样呢?
需要做何调整? |
|