Chapter 1 Object Oriented Programming

In this chapter, we’ll be taking a look at object oriented programming, or OOP. Whether you’ve used OOP before in PHP or not, this chapter will show you what it is, how it’s used, and why you might want to use objects rather than plain functions and variables. We’ll cover everything from the “this is how you make an object” basics through to interfaces, exceptions, and magic methods. The object oriented approach is more conceptual than technical—although there are some long words used that we’ll define and demystify as we go!

Why OOP?

Since it’s clearly possible to write complex and useful websites using only functions, you might wonder why taking another step and using OOP techniques is worth ...

Get PHP Master 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.