HomePHP Adding Validation to an Image Generator Class with PHP 5
Adding Validation to an Image Generator Class with PHP 5
Among the plethora of applications that can be developed with PHP 5, building dynamic image streams is one of the easiest to tackle. It requires only an intermediate background in the functions that come packaged with the powerful GD extension. This series of articles will teach you how to use this graphic library to build a highly expansible image generator class that can be used to create noisy images (also known as captchas).
Welcome to the second installment of the series that began with "Building a Image Generator Class with PHP 5." In accordance with the series title, these tutorials will guide you through the development of a highly pluggable PHP 5-driven class, which can be useful for embedding dynamically several input strings into a variety of popular graphic formats, including JPG, GIF and PNG.
If you already read the preceding article of the series, I assume that the logic implemented by the image generator class that I developed in that tutorial is now familiar to you. However, to clarify the way this class did its business, let me quickly refresh some key concepts regarding its programmatic functionality.
As you"ll probably recall, the class in question was provided with the ability to create dynamic image streams which contained an embedded text string that was logically passed as an input argument to the class constructor. Also, even though the structure of this class was rather primitive, it was flexible enough to allow us to perform some useful tasks, like displaying on the browser different text strings in a specific graphic format.
Of course, if you analyze the functionality of this image generator class, you might find it rather limited. Nonetheless, it"s possible to couple the class in its current version to other web applications, including banner and noisy images systems.
But, actually I'm getting ahead of myself. In this second part of the series I'll show you how to introduce some important modifications to the initial skeleton of the image generator class, to make it slightly more modular and independent, while maintaining its functionality nearly the same as before. Sounds pretty interesting, right?
So, having already introduced the subject of this second installment of the series, it's time to learn how to modify the original signature of this PHP 5-driven image generator class to improve its overall structure. Are you ready to begin? Let's get started!