php abstract class | Defining and using abstract classes in PHP

Abstract Class

An abstract class in OOP is the one that can only be inherited and cannot be instantiated.

Syntax of Abstract Class

 abstract class AbstractClass_name {

abstract function AbstractFunction_name() {

}

}

The abstract class is declared by using abstract keyword followed by class keyword and class name. Functions inside abstract class should also be created using abstract keyword.

All functions marked as abstract in parent class must be defined by child class.

Also see PHP Class

Was this article helpful?

Related Articles

Leave A Comment?