Problem Statement
What is an abstract class in PHP? Give an example.
Explanation
An abstract class cannot be instantiated directly. It can contain abstract methods that must be defined by child classes. Abstract classes are useful when creating a base class for related objects.
Example:
abstract class Animal { abstract function sound(); }
class Dog extends Animal { function sound(){ echo 'Bark'; } }
Code Solution
SolutionRead Only
abstract class Shape { abstract function area(); }