What is the significance of declaring a class as abstract in PHP when it contains an abstract method?
Declaring a class as abstract in PHP when it contains an abstract method means that the class cannot be instantiated directly. It serves as a blueprint for other classes to inherit from and implement the abstract method. This enforces the implementation of the abstract method in the child classes, ensuring that they provide their own implementation.
abstract class AbstractClass {
abstract public function abstractMethod();
}
class ChildClass extends AbstractClass {
public function abstractMethod() {
// Implementation of the abstract method
}
}