本文介绍了什么是CodeIgniter中的超级对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在中看到了超级对象一词,但是

I saw the term "Super Object" in CodeIgniter manual, but the term is not explained in details.

推荐答案

方案

codeigniter超级对象是一个对象,它允许你引用任何加载的代码信号器资源或加载新的代码,而无需每次初始化类。

The codeigniter super object is the object that lets you refrence any loaded codeigniter resource or load new ones without initializing the classes each time.

function whatever()
{
    $this->ci =& get_instance()  // sets an object in your library to point to the codeigniter object
    $this->ci->db->get('mytable');
}

在控制器中它只是

function whatever
{
    $this->db->get('mytable);
}

这是因为库默认没有对codeigniter对象的引用出于很多原因)

this is because libraries do not have a refrence to the codeigniter object by default (for many reasons)

这篇关于什么是CodeIgniter中的超级对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 00:19