So, if you’re a PHP developer who wants to learn how to put these magic functions to work for you in a truly effortless way, or wishes to fill some gaps in your knowledge regarding their correct implementation and usage, then this group of tutorials might be the guide that you’re looking for. And now that you know what to expect from this series of articles, it’s to review the topics that were discussed in the last one. In that particular tutorial I discussed the implementation of a destructor method within a simple class, via the pertinent “__destruct()” function. In that particular situation, this function was provided with the capability to save an instance of the originating class to a session variable before being destroyed by the PHP interpreter. In doing so, I hopefully demonstrated how to create basic persistent objects by using only a simple destructor. Not too bad at all, right? However, PHP 5 offers yet another magic method that can be extremely useful for loading classes automatically, without having to use explicitly any “include()/include_once()” or “require()/require_once()” function. As the article’s title suggests, I’m talking specifically about the “__autoload()” function, which deserves a deeper analysis. Therefore, this last chapter of the series will be focused exclusively on exploring the potential of this function for including classes in a transparent way. So, jump ahead and start learning more about it!
blog comments powered by Disqus |