build-website-header
 

Adding Repetitive Content Using PHP

 

To illustrate how powerful scripting like PHP can be for including content I am going to create a web page entirely from included files.

 In effect I will be creating the beginnings of a content management system.

What you will see here you will see in systems like Wordpress and Joomla etc, however much more complex.

The workhorse is a simple PHP include statement as you will see. What I am going to show is a simple web page split into three components

Header   -uses Page header.php
Main content  -Uses page main.php
Footer  - uses Page footer.php

Here is the Index.php that pulls the pages in:

<?php


include("header.php");
include("main.php");
include("footer.php");

?>
 

See how simple it is. Here are the three pages that it includes:


header.php

<html>
<head>
<title>the is the page title</title>
</head>
<body>
To menu bar


Main.php

<P>Main part of the page goes here</P>


Footer.php

Copyright
</body>
</html>

Here is what it looks like when you open the index.php page

Resources:


 

spacer2-image