$CI =& get_instance();
来源:互联网 发布:漆黑优化速度插件下载 编辑:程序博客网 时间:2024/06/06 07:15
要你自定义的类库中访问CodeIgniter的原始资源,你必须使用 get_instance() 函数.这个函数返回一个CodeIgniter super object.
一般来说在你的控制器函数中你可以通过 $this 调用任何可用的CodeIgniter函数:
$this->load->helper('url');
$this->load->library('session');
$this->config->item('base_url');
etc.
$this, 只直接作用在你自己的控制器,模型和视图中.当你在自定义类中想使用CodeIgniter原始类时,你可以这样做:
首先,定义CodeIgniter对象赋给一个变量:
$CI =& get_instance();
一旦定义某个对象为一个变量,你就可以使用那个变量名 取代 $this:
$CI =& get_instance();
$CI->load->helper('url');
$CI->load->library('session');
$CI->config->item('base_url');
etc.
注意: 你将注意到get_instance()这个函数通过被引用的方式被传递:
$CI =& get_instance();
这十分重要. 通过引用的方式赋给变量将使使用原始的CodeIgniter对象,而不是创建一个拷贝
同时,请注意: 如果你使用php 4,那么请最好不要在类的构造函数中调用 get_instance() .php4在引用位于构造函数中的CI super object时存在问题,因为对象只有在类完全实例化后才存在.
一般来说在你的控制器函数中你可以通过 $this 调用任何可用的CodeIgniter函数:
$this->load->helper('url');
$this->load->library('session');
$this->config->item('base_url');
etc.
$this, 只直接作用在你自己的控制器,模型和视图中.当你在自定义类中想使用CodeIgniter原始类时,你可以这样做:
首先,定义CodeIgniter对象赋给一个变量:
$CI =& get_instance();
一旦定义某个对象为一个变量,你就可以使用那个变量名 取代 $this:
$CI =& get_instance();
$CI->load->helper('url');
$CI->load->library('session');
$CI->config->item('base_url');
etc.
注意: 你将注意到get_instance()这个函数通过被引用的方式被传递:
$CI =& get_instance();
这十分重要. 通过引用的方式赋给变量将使使用原始的CodeIgniter对象,而不是创建一个拷贝
同时,请注意: 如果你使用php 4,那么请最好不要在类的构造函数中调用 get_instance() .php4在引用位于构造函数中的CI super object时存在问题,因为对象只有在类完全实例化后才存在.
- $CI =& get_instance(); codeigniter
- $CI =& get_instance()
- $CI =& get_instance();
- $CI =& get_instance();
- $CI =& get_instance(); 第二次转,说明的更清晰
- CI框架关于& get_instance()的解说
- 关于CodeIgniter中get_instance() 函数
- ci
- ci
- CI
- ci
- const int *const& p = &ci;的理解
- Docker+Git+Jenkins+Cloud VM=CI+CD
- HG - Hexo + GitHub + Travis CI = 自动部署博客实现
- .NET Core+Selenium+Github+Travis CI =- SiteHistory
- .NET Core+Selenium+Github+Travis CI => SiteHistory
- CI Principle
- CI钩子
- Linux内核编程初体验 —— hello world
- uc mobile 8.XX 以下,怎样访问内网
- 【C++基础之十七】抑制由构造函数定义的隐式转换
- Android View.onMeasure方法的理解
- Hash树
- $CI =& get_instance();
- tcp三次握手和四次挥手
- 常见10种算法
- HDU 2594 Simpsons’ Hidden Talents KMP的next数组应用
- 会计,你该如何面对新科技?
- 在Python中使用protocol buffers参考指南
- 输入5个字符串,排序后输出!
- linux sed编辑总结
- 输出js及时刷新页面