HomePHP Processing File Data with Template Classes in PHP 5
Processing File Data with Template Classes in PHP 5
If you're looking for a friendly guide on how to implement the template design pattern with PHP 5, then this group of articles might be what you need. Welcome to the final installment of the series that began with "Working with template classes in PHP 5." As the title indicates, this series steps you through creating template classes in PHP-controlled development environments, and also shows you how to use this rather uncommon pattern in real-world situations.
Stepping back for a moment to the preceding article of the series, you'll remember that I demonstrated via a step-by-step process not only how to build a template class in PHP, but how to use it in conjunction with a few handy subclasses. Indeed, the purpose of developing the programmatic model dictated by the pattern was simply to create a group of interrelated classes, which were capable of applying different (X)HTML formatting tags to a given MySQL result set.
Of course, if you already understand how the aforementioned example worked, you shouldn't have major problems grasping all the code samples that I plan to include in this final article of the series. Why do I say this? Well, to be frank, I believe that the best way to understand the logic of a given pattern is by demonstrating its implementation with numerous hands-on examples.
Therefore, taking into account this important premise, over the course of this last tutorial I'm going to provide you with a few more examples of how to build template classes with PHP 5. More specifically speaking, what you're going to learn here will be how to create a set of template objects that will control the visual appearance of data fetched from different files.
Logically, according to the definition imposed by the template pattern, there will be a base class responsible for setting up a specific algorithm via one of its methods, and other subclasses that will use the algorithm in question.
All right, having established the objective of this article, it's time to move on and keep learning how to build template classes in PHP 5. Let's begin now!