|
发表于 2011-11-16 10:07:31
|
显示全部楼层
haohailuo 发表于 2010-6-2 12:12
myconfig.php文件里面的数组格式应该为:
$config['myarray'] = array('name'=>'xiaoming');
版主啊,你好,有个问题想请教下你,我该怎么在controller里面加载我的config.php文件啊,我想读取config.php文件里面数组的内容。我的control文件如下:
<?php
class Start extends CI_Controller {
var $base;
var $css;
function Start()
{
#parent::CI_Controller();
$this->config->load('config');
$this->base = $this->config->item('base_url','config');
$this->css = $this->config->item('css');
echo $config['css'];
}
function index()
{
$data['css'] = $this->css;
$data['base'] = $this->base;
$data['mytitle'] = 'Welcome to this site';
$data['mytext'] = "Hello, now we're getting dynamic!";
#$this->load->view('testview', $data);
}
}
?>
可是会保错:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Start:config
Filename: controllers/start.php
Line Number: 8
Fatal error: Call to a member function load() on a non-object in D:\phpnow\htdocs\CodeIgniter\application\controllers\start.php on line 8
是不是我对codeigniter的语法理解有错误啊?请帮忙啊。谢谢啦。。。 |
|