Interested in an example of polymorphism, with code.
Closed due to the fact that the essence of the question is not clear to the participants: Igor , pavel , user194374, Denis , Alex 25 Nov '16 at 10:35 .
Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .
|
1 answer
abstract class Abastact { public function do(); } class Class1 extends Abastact { public function do() { echo 'class1'; } } class Class2 extends Abastact { public function do() { echo 'class2'; } } The meaning of polymorphism is that, no matter what object you get ( Class1 or Class2 ), it will definitely have an interface of the Abastact class. This behavior is useful when the object is obtained dynamically.
|