PHP overloading a function from a parent class?

Call parent::Save() in the subclass version of the method See php.net/manual/en/keyword.parent.php.

Call parent::Save() in the subclass version of the method. See php.net/manual/en/keyword.parent.php .

– user132014 Jul 10 '10 at 7:25 Hmm okay, I knew that was possible but I kinda thought PHP would look in all inherited classes for equal functioncalls and then execute them. But thanks for your answer, I'll add the line in all Controller_##-classes. – Ben Fransen Jul 10 '10 at 7:27 Edited.

It's just that the intuitive understanding is that the parent does something, and then the child extends on what the parent has done. So parent::Save() usually comes first. – Borealid Jul 10 '10 at 7:28.

Or you could apply refactoring to extract common behavior to your core class : class Controller_Core { public function save() { if (! $this->_validateInfo() ) { return false; } return $this->_doSave(); } protected function _validateInput() { //-- do stuff return true; } protected function _doSave() { //-- do stuff return true; } } You write the specific code in the children classes, as in : class Controller_Extended extends Controller_Core { protected function _doSave() { //-- a new return return true; } }.

I have several Controller_## classes, they all extend from Controller_Core. Each Controller_##-class has a public function Save(). Now I figured that I want to perform some other general checking (addslashes for each $_POST-var) and thought if I add a public function Save() to the Controller_Core it would be executed by default because the ##-class extends from it.

However, this is not the case. My question; is it possible what I'm trying to achieve?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions