I studied code igniter. and I come across this super object.
The code igniter has a function that loads classes and stores them in an instance variable. Each time we need to include a new class or a previously loaded class, the code igniter first looks for it in the array of instances, and if it is not found, load it and include it in the instanc array.
My question is in the class, when can we turn on the class using the load_class function (since this function first looks in the insntance array, therefore, it reduces the overhead of including the same class again and again), so I need to declare a super object to include predefined or loading new classes.
When can we do it?
class CLASSNAME { function functionname() { $object = load_class(classname, location); $object->callfunction(); } }
So why do we have to do this?
class CLASSNAME { function functionname() { $superobject = & get_instance(); $superobject->classobject->function(); } }
I just want to know the advantage of using a super object. Is it just to include all the predefined objects or something deeper and more useful that I could not understand.
Thanks in advance.
source share