PHP abstract Keyword

PHP and Keyword
PHP xor Keyword

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();
?>
PHP and Keyword
PHP xor Keyword

Stay up-to-date about PHP!

We don’t spam!

en English
X
Scroll to Top