class - 如何在 CodeIgniter 中创建库类的多个实例?

标签 class codeigniter instance

我想在 CodeIgniter 中创建一个类的几个实例。我已将我的类创建为一个库,但无法弄清楚用于创建多个实例的语法。

最佳答案

来自 CodeIgniter 用户指南:

CI Users Guide: Loader Class

Assigning a Library to a different object name

If the third (optional) parameter is blank, the library will usually be assigned to an object with the same name as the library. For example, if the library is named Session, it will be assigned to a variable named $this->session.

If you prefer to set your own class names you can pass its value to the third parameter: $this->load->library('session', '', 'my_session');

// Session class is now accessed using:

$this->my_session



我想这就是你要找的。

关于class - 如何在 CodeIgniter 中创建库类的多个实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/693260/

相关文章:

php - 在 Codeigniter 3.0.6 中插入当前日期时间

php - 如何在 CodeIgniter 迁移中使用 down() 方法?

php - 从 PHP 中的子类访问 protected 方法

ssh - 为什么我无法 ssh 到 GCP 中主机名的实例?

php - 如何在 PHP 中获取当前类的所有属性而不是其父类

c++ - 如何在C++中使用另一个类的成员变量?

C++:定义类函数的 .cpp 文件中实例本身的表示关键字

python - 打印类实例列表的随机实例但得到 RecursionError python3

我不明白的 C++ 错误 : syntax missing ';' before identifier

python - 如何使用静态方法初始化类变量?