What Have You Accomplished?

Using the syntax of PHP 4, you have created a class to assist in the display of images in a web page. It is a fairly simple class, and it should be readily apparent how the same job could be done procedurally.

However, despite the simplicity of the class and of the task it performs, there are some obvious advantages. On the plus side, you could say the HTML page is fairly clean—the somewhat messy task of determining if all files are image files has been hidden away inside the class file. Additionally, if you want to reuse this code, you won't have to cut and paste the way you so often do with procedural programming; you need only use the require directive with the class filename, and away you go.

But would you want ...

Get Object-Oriented PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.