Abstract Class
An abstract class is a class that cannot be instantiated directly. It has the abstract option.
An abstract class serves as a blueprint for other classes that extends it, and is intended to be subclassed. It is still possible to access its constants, static properties and static methods.
An abstract class can contain both regular methods and abstract methods. Regular methods provide common functionality that can be inherited by subclasses, while abstract methods are declared without an implementation. Subclasses of an abstract class must provide an implementation for all the abstract methods defined in the abstract class.
<?php
abstract class AbstractClass {
abstract function trumpet(); // abstract method
function forage() {
return 1;
} // concrete method
}
class ConcreteClass extends AbstractClass{
function trumpet() {
return 2;
} // concrete method
// No need to redefine the concrete methods.
// Yet, it is still possible
}
?>