Chapter 3Objects and OOP

In this book, we'll be using the Object Oriented Programming (OOP) paradigm. With OOP, we can create "objects" that combine data and the functions that operate on that data together. Because objects in OOP collect data and the functions that work on them in one place, we keep our code organized and can better manage complexity as our application grows.

The code that we write to define an object is called a class. One way to better understand the relationship between classes and objects is to think of a home builder. The builder—PHP for our purposes—follows a blueprint (a class) to build a house (an object).

Just as a builder can construct several houses using the same blueprint, so too can PHP create multiple instances ...

Get Jump Start 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.