in your example you'd want something like this -
require('header.htm');
switch($_GET['page']) {
case 'page1':
require('page1.htm');
break;
case 'page2':
require('page2.htm');
break;
default :
die("This is not a page I recognise");
}
require('footer.htm');
However, what I prefer to do is define a header and footer in a function, for example -
displayHeader($pageTitle, $styleSheet) {
$content = '<html tags etc here>';
$content .= '<title>'.$pageTitle.'</title>';
$content .= '<css include here src="'.$styleSheet.'">';
return $content;
}
displayFooter() {
$content = '<closing tags here>';
return $content;
}
displayBody($pageContent) {
$content = '<body tags here>';
$content .= '<page layout tags, ie master divs etc>';
$content .= $pageContent;
$content .= '<closing page layout tags here>';
return $content;
}
////////////////////
You then put these functions in your defaultfunctions file and on every page you create you can just create page1.php and have the following lines,
$pageContent = 'This is content specific to page 1';
$content = displayHeader('Page 1', 'main.css');
$content .= displayBody($pageContent);
$content .= displayFooter();
echo $content;
This gives you massive scope for loads of neat tricks, self-generating navigation, multiple views per page (ie reload the page with a different css, print.css for a print view). All your page layouts will be pixel perfect to the master as well, no need for copious copying and pasting, just define a main DIV that holds all the changing content on that page.
Instead of echo $content at the end you can write it to a HTML page, call the HTML page
$filename = date("h").'htm';
and your first visitor that hour creates a html page of your dynamic site which you can then re-use instead of dynamically generating each time.
Andrew