Header and Footer

How to have my header portion in a single file and use it accross at all files?
What is a header and footer in html?


It is very simple to do this using php.
Most of the commercial website use common header and footer files. It will be so helpful because when we want to change any information it is enough if we do it in a single file rather than duplicating it.
It will be so easy to add the change just in single file instead of all the files we have.
Follow the steps to do it yourself
Step 1:
Create a file as head.php and have all your header info in it
Example:You will have something like this in head.php
<table width=80% height=30>
<div align=center> Page Title </div>
//Other links for home,support etc.....

Step 2:
Now create your main files. In all the files just use "include" to have the header.
Lets say we have index.php, the code in it will look like this
include 'head.php';
<table width=80% height=100%>
//All you contents to follow

Note: So the header file head.php will be included in all files which will have a common header. The same thing can be done for footer too. Make sure that all the files are named with .php extension.

PHP Topics

Ask Questions

Ask Question