Welcome Guest, Not a member yet? Register   Sign In
Auto Loading Classes in Library
#1

[eluser]CodeIgniterNewbie[/eluser]
According to http://ellislab.com/codeigniter/user-gui...oader.html:

Quote:"Auto-load" feature that permits libraries...to be initialized automatically every time the system runs

1. In the case of classes within the library, does "initialize" mean "instantiate?"

2. If "initialize" does mean "instantiate", then does the object have a global scope? Particularly, does this object persist between the models, views, and controllers?

3. Another question about persistence: does the object persist between the controller's page loads? (Based on my testing, it does not. If this is true, is there a way to persist the object between page loads without using serialize() or memcache?)

4. Assuming "initialize" does mean "instantiate", how do I instantiate more of these objects?
#2

[eluser]Pascal Kriete[/eluser]
1. Yes, it means instantiate.
2. It gets bound to the CI super object, which all models, views, and controllers inherit from. Usually accessed through $this. Alternatively, you can get reference to the super object with get_instance();
3. It does not, this is true for any php script. What exactly do you need to keep? Will sessions do the trick?
4. The autoloader first includes the file, and then instantiates the class. So the class is available and you can instantiate another with new Name();

Hope that helps.




Theme © iAndrew 2016 - Forum software by © MyBB