Chapter 4. Object-Oriented Programming

In This Chapter

  • Understanding object-oriented programming

  • Planning an object-oriented script

  • Defining and writing classes

  • Dealing with errors by using exceptions

  • Copying, comparing, and destroying objects

Object-oriented programming is an approach to programming that uses objects and classes. Object-oriented programming is in widespread use today, with many universities teaching object-oriented programming in beginning programming classes. Currently, Java and C++ are the most prevalent languages used for object-oriented programming.

Object-oriented programming, with a limited feature set, is possible in PHP 4. With PHP 5, the object-oriented capabilities of PHP were greatly improved, with both more speed and added features. The information and sample scripts in this chapter are written for PHP 5. Features that aren't available in PHP 4 are noted.

Get PHP & MySQL® Web Development All-in-One Desk Reference for Dummies® 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.