H I O X INDIA
Online PHP Tutorial
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Templates 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)
Español Français 中文 Deutsch Portuguese Japanese தமிழ்
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

PHP Topics
Introduction
Syntax
Data Types
Variables
Operators
Control Structures
Functions
Pre-defined Function
Calendar Functions
Date and Time
Array Functions
Array Functions List1
Array Functions List2
Math Functions
PHP Mysql Functions
File Handling
Error Handling
DB Size
PHP Mail
String Tokens
String Functions
String Functions List1
String Functions List2
Session Functions
Cookies Functions
Form Variables
Running PHP from JS
Array To JS
Array to PHP
Encryption
Common Header
Ask Your Doubts
More about PHP
Feedback





Header and Footer


Topic

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?



Explanation

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
<html>
<head>
</head>
<body>
<table width=80% height=30>
<tr>
<td>
<div align=center> Page Title </div>
//Other links for home,support etc.....
</td>
</tr>
</table>


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

<?php
include 'head.php';
?>

<table width=80% height=100%>
<tr>
<td>
//All you contents to follow
.......
......
</body>
</html>


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.




privacypolicy     licence     sitemap
© 2004-2010 HIOX INDIA