Abstract in php with example

We can look to abstract class as a parent class with extends in the child class, and the child method must redeclare the parent abstract method.

How to Declare an Abstract class in PHP

You can use abstract keyword to declare abstract class and method

abstract class UserData{
  abstract public function is_allow();

now we will inherit this abstract class 

	class login extends UserData{
		public function is_allow()
			// code...

	$login = new login();

child class which extends from an abstract class must follow these rules:

  1. you cannot make-instance from an abstract class
  2. You cannot add an abstract keyword on a non-abstract class
  3. all child class must have the same name of all abstract method