Undoubtedly, the release of PHP 5 has had a remarkable impact on the way that object-oriented applications are developed nowadays. This highly-improved model has provided PHP programmers with features that were only present in mature object-based languages, like Java and C++, but now, fortunately for you and me, they are generously offered by this powerful server-side scripting language.
Of course, if you’ve been using PHP 5 for a while to build your object-oriented applications, then it’s likely that you’re already familiar with creating classes, defining their corresponding methods and properties, working with exceptions and interfaces, and so forth.
However, even when all of the features that I highlighted actually comprise the foundations of the so-called object-based paradigm, it’d be rather unfair not to mention other useful characteristics that come packaged with PHP 5, which can help facilitate the development of object-oriented projects.
Destructors and object deferencing are good examples of certain characteristics available in PHP 5, which can be extremely helpful when working with objects that need to be called when they no longer exist in the context of a given web application, or when a certain number of these objects must be chained with each other through their corresponding APIs.
Nevertheless, among the improvements introduced into the object model provided by PHP 5, there’s one in particular that can be considered a programmer's best friend when using objects, due to its remarkable functionality. Do you think that I’m being too verbose here? Well, maybe, but this won’t stop me from telling you loud and clear the name of the improvement in question. Yes! You guessed right! In this case, I’m talking about the useful “__autoload()” PHP 5 magic function, which can be really magical when it comes to automatically loading all the class files required by a determined PHP application.
As you might know, the “__autoload()” function, when used in a clever way, can eliminate almost completely the need to use the “require()/require_once()” and “include()/include_once()” PHP native functions to load your nicely-crafted classes automatically during the execution of an object-oriented application. This certainly speaks for itself about the powerful capabilities offered through this function.
Personally, when I started “auto loading” all of my PHP 5 classes with this magic function, I realized that it was one of those things one can’t live without. Hopefully after you go through this series of articles, you’ll feel the same way.
Actually I’m getting ahead of myself, so now is the perfect time to move forward and start learning how to put the “__autoload()” magic function to work for you, and load your classes without having to include them manually into your PHP 5 object-oriented applications. It’s going to be an educational experience. Believe me!