Right, I've now got this to work and to include the entire document declaration and header. It's not elegant and I invite anyone with more experience to produce an elegant solution. Here it is.
Create an include file (I just use txt) containing the following (alter or delete the details as you please):
<?php
// Create variables for XHTML dtds
$strict = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n\n";
$transitional = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n\n";
$frameset = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n\n";
$dtd = array (1 => $strict, $transitional, $frameset); // Create dtd selection
function xhtml_header ($dtd, $title) {
print $dtd;
print "<head><title>" . $title . "</title>\n\n";
print "<meta http-equiv=\"charset\" content=\"iso-8859-1\" />\n";
print "<meta name=\"author\" content=\"Author\" />\n\n";
print "<link rel=\"stylesheet\" type=\"text/css\"\n href=\"stylesheet.css\"></link>\n\n";
print "</head>\n\n";
return;
}
?>
In your actual php/xhtml files, type in the following right at the top. Insert your own title and change the index to 1, 2 or 3, corresponding to strict, transitional or frameset. Of course you can redefine the array to use any index you want:
--------------------------
<?php
include ("XHTMLdoctype_func.txt"); // Access function file
$title = "My title"; // Choose your title
echo (xhtml_header($dtd, $title)); // Call the header function
?>
---------------------------
That's it. Tested on Win98 with Apache 2.0.42, PHP 4.01 and IE5. Anyone want to improve on this?
Best of luck
Norman