Problem Statement
Explain polymorphism in PHP with example.
Explanation
Polymorphism means one interface, many implementations. In PHP, it allows different classes to define methods with the same name but different behaviors. It improves code flexibility.
Example:
interface Shape { public function draw(); }
class Circle implements Shape { function draw(){ echo 'Drawing Circle'; } }
class Square implements Shape { function draw(){ echo 'Drawing Square'; } }
Code Solution
SolutionRead Only
interface Shape { function draw(); }