Where to Go from Here

We've touched on three topics central to OOP: classes, access modifiers, and inheritance. Classes define objects, access modifiers determine how objects can be used, and inheritance makes it easy to adapt objects for different circumstances. I've emphasized the ways in which procedural programming is like OOP with a view to easing the transition to an OO approach, but I've also shown important differences. A data type like a class, which incorporates functions, is unlike anything encountered in procedural programming. Additionally, OOP provides access modifiers to control how an object may be used. Instead of relying on documentation and a disciplined approach, OOP incorporates constraints into the language.

The next chapter ...

Get Object-Oriented PHP 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.