O'Reilly logo

PHP 5 Advanced: Visual QuickPro Guide by Larry Ullman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required