PHP abstract Keyword
Example
Create an abstract class:
<?php
abstract class MyClass {
public function hello() {
echo "Hello World!";
}
}
class AnotherClass extends
MyClass {
}
$item = new AnotherClass();
$item->hello();
?>
Try it Yourself »
Definition and Usage
The abstract
keyword declares a class as abstract.
Abstract classes cannot be instantiated but they can be extended.
Related Pages
Read more about abstract classes in our PHP OOP - Abstract Classes Tutorial.
❮ PHP Keywords