www.  
Frequently Asked Questions
Tutorials
AIHOST Forums
Contact AIHOST Support

 

PHP Tutorial

How do I implement headers and footers using PHP?
PHP can be used to streamline your coding by setting up site-wide header and footer templates. Updates and maintenance are much easier to maintain with separate files dictating site look & feel.

Your first step to designing your headers and footers is to build your html header/footer. Your file can be named any of the following: .inc, .php3, .html, .htm, .txt The include will parse out whatever is within the "included" file.

Typically you would build your section, menuing system and/or body tag in the header. Footers might include contact or copyright information.
An example is below:
<html>
<head>
<title>Web page Title</title>
</head>
<body BGCOLOR="#FFFFFF">
<H1>Welcome!</H1>

Or you could create a more dynamic header that gets the title and page variables when the include is called. This would be similar to the following:
<html>
<head>
<title>$pagetitle</title>
</head>
<body BGCOLOR="#FFFFFF">

Calling the header and footer in the document
Now in the main body of your document call the header or footer you created.
<?PHP
include ('/includes/header.php3');
?>

Typically a programmer makes a folder "includes" for all of the various files they'll include throughout the website: i.e. headers, footers, database calls etc. This makes it easier to find all the files for editing and updating your site.

For more dynamic content
For more dynamic content pass your variable while you call the header/footer with your include command.
<?PHP
$title = 'Name of Site';include ('/includes/header.php3');
?>

 
 

 
Online Forums  ::   Services ::   About Us  ::   Support  ::    Contact Us  ::    Login  ::    Home  
AIHOST.NET™ 2006. All rights Reserved, Powered By TelNex Technologies, Inc.