php class inheritance - is it necessary to run constructor on parent(s) -


I'm trying to use OOP for my latest website. I am using the project to develop my understanding of this technique. First I was 'included' in a function folder that contains several php files, such as image .upload.functions.php and normal .error.handling.functions.php etc.

However, this time I am using classes wherever possible.

I have just read that in order to use a parent's methods (in an extended class) you should run the parent's constructor, but I have not done this and my project works fine Does.

So .. I have a form called Form Validation, I have another class named Process Log, which extends form validation.

My form validation class tests the strength of the password to make sure it is strong enough, check that a user is in database etc.

I extend the form verification with a registration class and a forgotten passhold class.

I should have felt: / P>

  parent :: _ construct ();  

.. In the manufacturer of each extended class?

Did anyone say 'just' the reason why do we do or do not do this? Is this something that I should do?

Many thanks: -)

Here's a link to the official document:

And here's the quote:

Note: To define the constructor, the original constructors are not called implicit, to run the parent constructor, the hair constructor In Parent :: __ Consultation (), call is required. If the child does not define a constructor then it can be obtained from the parent class like normal class system (as if it was not declared as private).

Calling parent constructor is not necessary. And, in general, it is not called exclusively if you have defined constructor in your child's orbit. But, if you have a good part of logic or functionality in the original manufacturer, then you do not want to lose, then call the parent's constructor a child.


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -