In this article, you will learn how to declare an abstract class in PHP. The abstract keyword in PHP declares a class as abstract. Abstract classes cannot be instantiated but they can be extended.
examples of the ABSTRACT keyword
Example 1. In this example, we create an abstract class.
<?php
abstract class MyClass {
public function hello() {
echo "Hello World!";
}
}
class AnotherClass extends MyClass {
}
$item = new AnotherClass();
$item->hello();
?>