td204

Web development, one post per year since 2002

2003 in review: a stylesheet, and a platform instead of a page

I had been writing PHP for a while by 2003. What changed this year is what I pointed it at: my first stylesheet, a database behind a site rather than beside it, and a platform that other people could sign up to instead of a site I handed over when it was done.

PHP, used as a very good include

Most of my PHP that year was not clever. It was the fix for the problem I complained about last year: fifty copies of the same navigation.

<?php include("begin_html.php"); ?>

<h1>Page title</h1>
<p>Content goes here.</p>

<?php include("end_html.php"); ?>

Two includes, one header, one footer, and suddenly a menu change is one edit. I have the files still. The header opens with HTML 4.01 Transitional, sets charset=iso-8859-1, links a stylesheet and an RSS feed, and pulls in a JavaScript tooltip library. For 2003 that was a reasonably modern page.

Everything else followed from that. A database connection. A page that counted who was online. A cron job. None of it was architecture. It was a series of small realisations that the server could do work instead of me, and each one made the next site cheaper to build than the last.

A stylesheet, finally

One .css file this year, against nine hundred images. The proportion tells the story: CSS was where you put text colours and link styles, and layout was still a table. The idea that you could lay a page out in CSS existed, and the browsers made it a bad bet.

But the separation started here, and the first time you change the link colour of an entire site by editing one line, you do not go back.

Building a platform instead of a page

The project I am proudest of from that year is a free hosted weblog service: anyone could sign up and get their own blog. Written in plain PHP, with templates, user accounts, an RSS feed and a cron job.

Building something multi-tenant teaches you things a brochure site never will. Chiefly: user input is hostile, and every single query I wrote that year concatenated strings straight into SQL. That code would not survive ten minutes on today's internet. I did not know what SQL injection was, and nobody who deployed PHP in 2003 was being asked.

And a webshop that was somebody else's code

The other big job was an e-commerce platform running on Smarty templates, which was my introduction to two lasting ideas: a template language that keeps logic out of the markup, and a codebase you did not write and cannot fully change.

In short

PHP stopped being scattered scripts and became structure: includes, a database behind the site, and a platform strangers could sign up to. First stylesheet, first SQL.