PHP Include
This shows you how to use the essential PHP include funtion.
An include is a PHP statement that allows you to insert the content of one page into another. This function is vital for creating web sites. The most common use for using include statements are for parts of your site that will be the same on all of your pages, like headers, footers, and the navigation. For each one (header, footer, and navigation) you would write the code in a separate file then call this file using a line of PHP code in each page of your site that basically says "Include the header here". So, if you have 20 pages on your site and you want to change the header you will only have to change one file instead of 20. Even if you have a site with only 1 or 2 pages I would recommend using an include file. It doesn't take any more effort to do, you won't have to do it later, and you get to learn how to do it.PHP Includes
PHP Page - homepage.php
|
<html> <head> <title>HTML tutorial</title> </head> <body> <?php include("header.php"); ?> Then your content goes here. Then your content goes here. Then your content goes here. Then your content goes here. </body> </html> |
||
PHP Page - header.php
|
<div style="padding: 6px; background: #a0c0a0;"> <span style="font-size: 22px; color: blue; ">YourSite.com</span><br> <span style="font-size: 12px; color: #0000ac; ">The best site on the internet.</span> </div><br> | ||
This is how it looks
|
YourSite.com The best site on the internet. Then your content goes here. Then your content goes here. Then your content goes here. Then your content goes here. |
||
Bookmark this page: |
Rate this page: |
Comments:
| please post comments | ||
|
admin November 21, 2006 |
||











