6.10. Abstract Methods and Abstract Classes

Object-oriented programs are built around class hierarchies. In a single inheritance language such as PHP, class hierarchies are trees. A root class has one or more classes that descend from it, with one or more classes derived from each of them. Of course, there may be multiple root classes, which implement different families of classes. In a well-designed hierarchy, each root class will expose a useful interface, which can be used by application code. If our application code is designed to work with a root class, chances are it will also be able to work with any specialized derivative of that class.

Abstract methods are methods that behave like placeholders for regular methods in derived classes and—unlike ...

Get Core PHP Programming, Third 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.