tags:

views:

33

answers:

1

Just a quick one. In OOP PHP, if I have a function defined in the parent class, and a modified version in the child class, and I call it from an instantiated object of the child class, will it use the child class's version of the function?

I am pretty sure it will just double checking, as there is no way for me to check within the running.

+3  A: 

Yes, it absolutely will.

If you want to use the parent's version too, you must call parent::the_func() within the child's override of that function.

You must also call a parent's constructor if you override the constructor in the child. It is not called automatically.

tandu