PHP abstract Keyword

❮ PHP Keywords

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
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.