Skip to Content
The Art of Modern PHP 8
book

The Art of Modern PHP 8

by Joseph Edmonds
October 2021
Intermediate to advanced content levelIntermediate to advanced
420 pages
7h
English
Packt Publishing
Content preview from The Art of Modern PHP 8

Chapter 2: Inheritance and Composition, Encapsulation and Visibility, Interfaces and Concretions

In this second chapter, we are going to learn as much as we can about the OOP features of PHP when it comes to creating full sets of classes that are related to each other and that work together to provide a specific feature.

First, we are going to learn about encapsulation and the differences between private, protected, and public class properties and methods. Hopefully, you will see the advantage of keeping things as private as possible.

Then we are going to look in detail at the two main ways of creating a graph of related and interdependent classes: classic inheritance and the alternative approach of composition.

As we explore this, I hope that ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Modern PHP

Modern PHP

Josh Lockhart
The PHP Workshop

The PHP Workshop

Alexandru Busuioc, David Carr, Markus Gray, Vijay Joshi, Mark McCollum, Bart McLeod, M A Hossain Tonu
PHP 8 Basics: For Programming and Web Development

PHP 8 Basics: For Programming and Web Development

Gunnard Engebreth, Satej Kumar Sahu

Publisher Resources

ISBN: 9781800566156Supplemental Content