PHP tutorial vastly improved
I have finally gotten around to updating my PHP tutorial. Our PHP class came up again in the rotation this week, and I decided I needed to take this as an opportunity to rewrite the tutorial. I wrote the old one so long ago I don’t remember1.
It occurred to me a couple of years ago that it might be easier to teach newcomers how to program using classes rather than a mess of functions and variables. For one thing, it would make it much easier to duplicate the same functionality for a different purpose, such as making the poll be about presidents rather than about imaginary characters.2
When I first wrote the tutorial, PHP was either still using or had just stopped using register_globals on by default, and if classes existed they were rudimentary. Today, it is by far easier to develop PHP code using classes than without them. We also have a much better concept of what it means to write code around HTML. We make our HTML pages templates that include functionality from elsewhere; any complex code is in include files (or in template engines) and only easy-to-read flow control goes directly in HTML pages.
The new tutorial shows how to handle simple forms, progressing through a favorite color to a simple poll system that can be customized to any list of items. It also shows how to extend the poll system to store data in a SQLite database instead of in a flat file.
The Wayback Machine has archives of this version on my web site as far back as 2003, but I don’t think I put it on the web site immediately, so I probably wrote it in the late nineties or 2000. The wayback machine version still has me using .phtml as an extension. I used that as the PHP extension because our users were still used to using .shtml for dynamic pages.↑
Which is not to say that most presidents aren’t perfectly fine imaginary characters.↑