Chapter 20. Introducing Object-Oriented PHP
There are many possible audiences for this chapter, including people who know basic PHP but nothing about object-oriented programming (OOP), and people who know all about OOP and nothing about PHP. As usual, we aim to please everyone all at once, but be warned that you may want to pick and choose from the sections.
We start with a quick and very general introduction to object-oriented programming for those who are completely unfamiliar with it. If you are already comfortable with OOP from another language, please skip this section — it will not enlighten you (and might well enrage you). The section "PHP Constructs for OOP" gets into the meat of the basic syntax and behavior of PHP objects. Later in the chapter, we delve into more extended examples and cover some of the more obscure issues and gotchas around objects in PHP. Along the way, we offer a couple of sidebar meta-discussions, about the merits of object-oriented PHP and the extent to which PHP should be considered to be OOP.
Note
In general in this chapter, we discuss OOP programming constructs as they are implemented in PHP5, which uses the new and significantly improved Zend Engine 2 as its parser.
What Is Object-Oriented Programming?
So what is object-oriented programming (OOP) all about anyway? OOP turns out to be a very simple idea, ...
Get PHP6 and MySQL® 6 Bible 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.