$CI =&get_instance()出错
本帖最后由 ywmprogrammer 于 2015-4-1 15:16 编辑在自定义类库中使用CI资源报错
class test {
public function bac()
{
$ci = & get_instance();
$ci->load->helper('other');
}
}
求大神啊,什么原因
补充:后面认真看代码发现是我写错了
没有继承CI类
class test extends CI_Controller {
public function bac()
{
$ci = & get_instance();
$ci->load->helper('other');
}
}
类继承:类名 extends CI_Controller mlym3075 发表于 2015-3-31 17:07
类继承:类名 extends CI_Controller
肯定是其他地方出错。
在CI的Controller里,不需要这么写, 用$this 就可以了:
$this->load->helper('helper');
$this就是 &get_instance()自己,源代码:
function &get_instance()
{
return CI_Controller::get_instance();
}
你的错误应该在其他地方。
报什么错都不说。。
页:
[1]