PHP Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
PHP Topics
Introduction Introduction
Syntax Syntax
Data Types Data Types
Operators Operators
Control Structures Control Structures
Functions Functions
Pre-defined Function Pre-defined Function
Calendar Functions Calendar Functions
Date and Time Date and Time
Array Functions Array Functions
Array List Array Functions List1
Array Function List Array Functions List2
Math Functions Math Functions
PHP MYSQL Functions PHP Mysql Functions
File Handling File Handling
Error Handling Error Handling
DB Size DB Size
PHP Mail PHP Mail
String Tokens String Tokens
String Functions String Functions
String Functions List String Functions List1
String Functions List2 String Functions List2
Session Functions Session Functions
Cookies Functions Cookies Functions
Form Variables Form Variables
Running PHP from JS Running PHP from JS
Array To JS Array To JS
JS Array Array to PHP
Encryption Encryption
Common Header Common Header
Forums Ask Your Doubts
Scraps More about PHP
Feedback Feedback
 




Header and Footer


Tutorials Php

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.





A Note

Learn PHP programming language tutorial with simple and neat example. Hope you enjoy this free tutorial. Do give us your valuable feedback and suggestions on this online tutorial. This is a Copyright Content.

Other Links

web hosting