Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic Polymorphism in PHP

Is Dynamic Polymorphism in PHP is supported like template classes or is the only way in using Polymorphism in PHP is abstract functions and overloading/overriding ?

like image 499
Sudantha Avatar asked Jun 04 '26 20:06

Sudantha


2 Answers

This should enlighten you: http://net.tutsplus.com/tutorials/php/understanding-and-applying-polymorphism-in-php/

like image 103
bcosca Avatar answered Jun 06 '26 09:06

bcosca


There is nothing like Template Classes, but you can very much achieve different runtime behavior through the use Abstract Classes and Interfaces as well as the utilization of Design Patterns like State, Decorator, Strategy and others.

related: Is what seems like polymorphism in PHP really polymorphism?

like image 43
Gordon Avatar answered Jun 06 '26 10:06

Gordon