PHP Abstract Class

PHP’s abstract class is a base class which will have abstract methods with no definition. Abstract classes cannot be instantiated or in other words, you cannot create an object of an abstract class. An abstract class can have non abstract methods also. Class which has at least one abstract method should always declare as an abstract class.

PHP Abstract Class Example:

We are going to have an abstract class called payment which will have a non-abstract class called “get_total_amount”, will return the total amount to checkout. Also, we will have an abstract method called “checkout” which should be defined in the child classes.


You may also like