12 June 2007



Started using PHP for my website to generate static pages and save myself a lot of cutting-and-pasting each time I made a new page; could have used Apache's Server-Side Include feature but I intend to write some interactive pages in the future. Here's the changes I've made so far:

XHTML / PHP File Structure

The structure of my XHTML / PHP files follows:

<?php include "php/xhtml_mimetype.php"; ?>
<html … >

<title>Title Text</title>
<?php include "php/head.php"; ?>

<?php include "php/header.php" ?>


<?php include "php/trailer.php"; ?>



While HTML tags are static, I left them in the XHTML file so that a text editor can match the opening and closing tags.


The xhtml_mimetype.php file generates the HTTP header and writes the XML declaration and DOCTYPE. See Serving XHTML with the correct mime type using PHP by Neil Crosby on how to generate headers for browsers that can and cannot support XHTML (such as MSIE6 and MSIE7).


head.php generates META and LINK tags.

header.php and trailer.php

header.php and trailer.php contain static boilerplate XHTML text and a function to write the last modified date.


Added PermanentRedirect directive for pages that are now generated using PHP. The rule is currently applied on a file-by-file basis until I have converted all my files from HTML or XHTML to PHP.