N
N
nikitakarpenko2018-06-22 16:43:33
PHP
nikitakarpenko, 2018-06-22 16:43:33

OOP Is child method called from parent class?

Is it possible to call a method in a parent class that is defined in a child class?
The first time I saw this ... maybe it seemed to me?
Usually the parent ones are called from the child.
Here is an example based on what I asked the question:
abstract class B extnds C {
function func_in_parent_class () {
$this->function_in_child_class()
}
}
class A extends B {
public function function_in_child_class () {
}
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Kim, 2018-06-22
@kimono

This is not a call to a child class method from a parent class. This child class can override the parent method.

A
alek_tost, 2018-06-29
@alek_tost

This pattern is called "Template method".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question