461288344 发表于 2016-9-9 17:06:09

CI构造函数里new后出错

构造函数
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

Hex 发表于 2016-9-9 17:15:42

CI 的类库不需要 new,请参考手册来使用 CI,不要按自己的想法去使用。

Aloghli 发表于 2016-9-9 20:10:10

看手册嘛先

a2si 发表于 2016-9-19 17:58:30

不需要 new
页: [1]
查看完整版本: CI构造函数里new后出错