我想在 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/