Object Oriented Programming
 
Introduction
 
While PHP 4 was the first version to offer Object-Oriented Programming (OOP) capabilities, many considered the feature to be poorly designed and more an afterthought than anything else. PHP 5 resolves many of the version 4 OOP inconsistencies, not to mention greatly enhances the language's object-oriented capabilities.
 
While you're still free to program using a procedural methodology, those of you with object oriented backgrounds will certainly feel much more at home creating fully object-driven PHP applications. In this article I'll introduce many of these new and improved features.
 
In addition, for those of you somewhat new to the subject, this article will also offer a bit of instruction regarding those concepts key to truly understanding OOP.
 
While for many languages object orientation is simply a matter of course, it took several years before such features were incorporated into PHP. Yet the early forays into adding object-oriented features to the language were considered by many to be a poor attempt at best.
 
Although the very basic premises of object-oriented programming (OOP) were offered in version 4, several deficiencies existed, including the following:
 
. An unusual object-referencing methodology
. No means for setting the scope (public, private, protected, abstract) of fields and methods
. No standard principle for naming constructors
. Absence of object destructors
. Lack of an object-cloning feature
. No support for interfaces
 
Thankfully, version 5 eliminated all of the abovementioned encumbrances, offering significant improvements over the original implementation, as well as a bevy of new OOP features. This chapter and the following aim to introduce these new features and enhanced functionality.