O'Reilly logo

PHP Quick Scripting Reference by Mikael Olsson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 15

image

Abstract

An abstract class provides a partial implementation that other classes can build upon. When a class is declared as abstract it means that the class can contain incomplete methods that must be implemented in child classes, in addition to normal class members.

Abstract methods

In an abstract class any method can be declared abstract. These methods are then left unimplemented and only their signatures are specified, while their code blocks are replaced by semicolons.

abstract class Shape{  abstract public function myAbstract();}

Abstract example

To give an example, the class below has two properties and an abstract method.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required