[Reprint] compile PHP header and bottom reference

Source: Internet
Author: User

1. Compile PHP header and bottom reference

[9:48:00 |:
Tong]
 
Each page has the same header and bottom. As shown in the preceding figure, the same information can be written to each page when the workload is low, but imagine how much effort you will spend when there are more than 100 pages and you need to change all of their headers or bottoms? How tedious and boring is manual changes on one page! Therefore, we should write PHP headers and bottom files for these pages, and then we just need to reference them in each HTML page. We will put these include files under a subdirectory named include. Next we will write the general content of these sites into the file.

General site variable settings: Common. inc
<?
// General site Variables
$ Myemail = "phptalk@tnc.org ";
$ Myemaillink = "<a href = \" mailto: $ myemail \ "> $ myemail </a> ";
$ Myname = "php talk ";
$ Mysitename = $ myname. "'s home page ";
?>

General page header: header. inc
<?
// Define the general page header
?>
<HTML>
<Head>
<Title>
<? Echo "$ mysitename-$ title";?>
</Title>
</Head>
<Body>
<H1>
<? Echo "$ mysitename";?>
</H1>
<H2>
<? Echo "$ title";?>
</H2>
<HR>

General page bottom: footer. inc
<?
// At the bottom of the general page
?>
<HR>
<P align = "center">
<Small> <I>
Copyright? By
<? Echo "$ myname ($ myemaillink)";?>
, 1999
</I> </small>
</P>
</Body>
</Html>

New Page front. php3:
<?
Include ("include/common. Inc ");
$ Title = "welcome ";
Include ("include/header. Inc ");
?>
<P>
Welcome to my cold house, although there is nothing at the moment.
</P>
<P>
But I hope I can add more immediately.
</P>
<?
Include ("include/footer. Inc ");
?>

New Cont. php3:
<?
Include ("include/common. Inc ");
$ Title = "Contact Information ";
Include ("include/header. Inc ");
?>
<P>
You can contact me through 1-800-php-info
</P>
<?
Include ("include/footer. Inc ");
?>

Now you can guess the benefits of this arrangement. If you want to change the header or bottom of the page, you only need to change the corresponding file. If you want to modify your e-mail address or even your name, you just need to modify the common. inc file. In addition, you can include files with any file name or extension in your file, and you can even include files on other sites.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.