views:

655

answers:

1

I'd like to create several instances of a class in codeigniter.

I have created my class as a library, but cannot figure out the syntax to use to create more than 1 instance.

+2  A: 

From the CodeIgniter users guide:

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

I think that's what you're looking for.

GloryFish
I am pretty sure he means:$one = new Class;$two = new Class('but_different');
Garrett