8. Real-World OOP
The preceding two chapters each discuss object-oriented programming, as it pertains specifically to version 5 of PHP (which has a drastically new object model and syntax). The majority of the examples in those chapters tend to be more demonstrative than practical (the Rectangle, Square, Shape, and Triangle classes are useful, though, but only if you’re doing geometric work). Philosophical examples are best for teaching OOP, I believe, but real-world object-oriented programming hammers the points home.
In this chapter I focus on two popular uses of OOP: exception handling and a shopping cart. The first subject is new to PHP 5 and worth knowing, even if you don’t regularly do object-based programming. The shopping cart example ...
Get PHP 5 Advanced: Visual QuickPro Guide 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.