Advanced PHP
June 3, 2026 1 min read

PHP Abstract Classes and Inheritance

HS
HEMANT SINGH
Technical Writer & Educator

The class declared with an abstract keyword is called an abstract class.

An abstract class has some special properties.

  1. It can not be initiated, the object of this class can not be created.
  2. it will always be inherent in other classes.
  3. It can contain abstract methods. (Methods declared with abstract keyword and do not have a body)
  4. Abstract is always implemented in the derived class.

Example

abstract class Database{
	public $server="127.0.0.1";
}

class User extends Database{

}
$user= new User();
echo $user->server;
$user->server="100";
echo $user->server;