Welcome Guest, Not a member yet? Register   Sign In
Library Constructors
#1

[eluser]USCTrojans[/eluser]
Hey could anyone help me understand the difference between the two different types of constructors available to use with code igniter?


In my c++ course we did constructors for a class by doing the function class() like this:

Code:
class Test {
      
        function Test(){
                constructor here

       }

this works but I have noticed that in code igniter libraries and in php in general you often see this:

Code:
function __construct(){
  parent::__construct();

}

I noticed the second one will overwrite the first one if they are both in a library but what is the difference? Which one should I be using?

Thanks

#2

[eluser]skunkbad[/eluser]
PHP5 = __construct() OR same_name_as_class()

PHP4 = same_name_as_class()




Theme © iAndrew 2016 - Forum software by © MyBB