Welcome Guest, Not a member yet? Register   Sign In
General and very basic question - The Parent Constructor Call
#1

[eluser]MEM[/eluser]
In all tutorials I read, I see:

class SomeThing extends SomeOtherClass {
function SomeThing()
{
parent::SomeOtherClass();
}
}

Newbie Question:
Why do we need to load the Parent Class on the constructor if we already extend that class?
As far as I've read, once we extend a class and we don't declare a construct method, the Parent construc method will be used instead. Isn't this correct ? If so, why this?

Thanks,
Márcio
#2

[eluser]pistolPete[/eluser]
[quote author="MEM" date="1250691908"]As far as I’ve read, once we extend a class and we don’t declare a construct method, the Parent construc method will be used instead.[/quote]

That is correct, you could leave out that constructor if all it does is calling the parent constructor.
#3

[eluser]wiredesignz[/eluser]
You are correct. If you require some additional functionality for the new class you would add it in the constructor as described and call the parent constructor manually. Otherwise the parent constructor is called automatically.
#4

[eluser]MEM[/eluser]
Perfect.
Thanks. Smile




Theme © iAndrew 2016 - Forum software by © MyBB