用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1113|回复: 3
收起左侧

[已解决] CI构造函数里new后出错

[复制链接]
发表于 2016-9-9 17:06:09 | 显示全部楼层 |阅读模式
构造函数
function __construct()
{
        parent::__construct();
        $this->load->model('tmp');
        $tmp = new tmp();//加上后就出错,在用到的方法里new就没这个错误
}

下面方法里的错误位置
$this->load->helper('form');
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('', '');

错误信息
PHP Fatal error:  Call to a member function set_error_delimiters() on a non-object in E:\work\trunk\dashboard\app\controllers\account_number\pnbind.php on line 70

我就想在构造函数里new另一个类的对象出来,可以在该类所有方法里调用,不需要每个方法自己new
发表于 2016-9-9 17:15:42 | 显示全部楼层
CI 的类库不需要 new,请参考手册来使用 CI,不要按自己的想法去使用。
发表于 2016-9-9 20:10:10 | 显示全部楼层
看手册嘛先

本版积分规则