PHP Framework

index.php

<?php
include '/path/to/lib/common.php';
 
$settings = array
(
   'title'        => 'My home page',
   'skin'         => 'lcars',
   'content_file' => 'index_content.php',
);
 
gen_html($settings);
 
?>

index_content.php

<div id="sidebar-base">
 <div id="sidebar-content-area">
  <!-- sidebar content -->
 </div> <!-- "sidebar-content-area" -->
 
 <div id="main-content-area">
  <!-- main content -->
 </div> <!-- "main-content-area" -->
</div> <!-- "sidebar-base" -->
 
<div id="footer-spacer">
 <div id="footer-spacer-side"></div>
 <div id="footer-spacer-main"></div>
</div>

common.php

<?php
 
// **UNCOMMENT TO DISPLAY ERRORS FOR DEBUGGING**
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);
 
function mydirname()
{
   return basename(realpath('.'));
}
 
function html_head($title, $skin)
{
   include '/path/to/lib/common_head.php';
}
 
function html_body($content_file)
{
   include '/path/to/lib/common_body.php';
}
 
function gen_html($settings)
{
   html_head($settings['title'], $settings['skin']);
   html_body($settings['content_file']);
}
 
?>

common_head.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
 
<head>
 
<?php $pver=phpversion(); echo "<!-- Page source dynamically generated with PHP version $pver -->\n"; ?>
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
<title>
   <?php echo "$title\n" ?>
</title>
 
<!-- Include skin's CSS -->
<?php
 echo "<link href=\"/pathto/css/$skin.css\" rel=\"stylesheet\" type=\"text/css\" />\n";
?>
 
</head>

common_body.php

<body id="skin-body">
 
<!-- Common content header -->
<div id="header-bar">
 <!-- header content -->
</div>
 
<?php include $content_file: ?>
 
<!-- Common content footer -->
<div id="footer-bar">
 <!-- footer content -->
</div>
 
</body>
</html>
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License