在自定义类的构造函数内初始化Codeigniter实用程序


Initializing Codeigniter Utilities inside contstructor on Custom Class

我做CI已经有几个月了,我想在CI上创建我自己的库类。现在,我的问题是,我似乎不能得到CI的实例,以便我利用它的本地资源。我已经做到了。

class MyClass{
     protected $instance;
     public function __construct()
     {
        $this->$instance = &get_instance(); <-- this is what i did (theoretically speaking)
     }
  }

我尝试过的其他事情

class MyClass{
     protected $instance = &get_instance(); <-- reports a syntax error on Apatana
     public function __construct()
     {

     }
  }

有谁能给我一个更好的主意关于如何获得实例(初始化它在源代码上的一点)<-据说,我只想获得实例一次,并在我的

中使用它
you can use it in this way
in constructor
$this->ci = & get_instance();
then you can use it like 
$this->ci->load->model();