© Mikael Olsson 2016

Mikael Olsson, PHP 7 Quick Scripting Reference, 10.1007/978-1-4842-1922-5_15

15. Abstract

Mikael Olsson

(1)Hammarland, Finland

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 following class has two properties and ...

Get PHP 7 Quick Scripting Reference, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.