The title and content of this page were included from 'cnt/home.php'.

The really beautiful thing about this template system is that PHP can be used in the content file!



Home Page index.php code:
<?php

require_once('inc/xhtml-or-html.php');

$title = "";
$head = "";
$content = "";

$requested_page = $_GET['page'];

if ($requested_page == "") {
	require('cnt/home.php');
}
else {
	$path = 'cnt/' . $requested_page . '.php';
	if (file_exists($path)) {
		require($path);
	}
	else {
		require("cnt/404.php");
	}
}

?>

<head>
	<title><?php echo $title; ?></title>
	<?php echo $head; ?>
</head>

<body>
	<div id="content">
		<?php echo $content; ?>
		&nbsp;
	</div>
</body>

</html>



Template File cnt/home.php code:
<?php
$title = "Simple PHP Template";

$head = <<<HEAD

<style type="text/css">
	...
</style>

HEAD;

ob_start();                   // start output buffer
require_once("home_cnt.php"); // content file
$content = ob_get_contents(); // assign buffer contents to variable
ob_end_clean();               // end buffer and remove buffer contents

?>



Content File cnt/home_cnt.php code:
The page title and content of this page were included from 'cnt/home.php'.
<br />
<br />
The really beautiful thing about this template system is that <?php echo "PHP can be used in the content file!"; ?>
<br />
<br />
Link to a page like this: <a href="?page=home">Home</a>
<br />
<br />
index.php code:

...

You get the point.