Advantage of PHP include page in web page design

web page design software
by Esthr

Article by susen

Advantage of PHP include page in web page design

PHP include page statement is an extremely useful statement to build WebPages. If you are very new in PHP or even don’t know it at all, you can also utilize this statement to manage your website.

Logically you can divide HTML code of a webpage into multiple segments. Some of those are static parts and others are variable parts. Static parts are those which do not change from page to page, i.e. top part of your page where you put your site name and banner, menu, bottom part of your page where you put copyright notice, etc. Variable parts of your page are the elements which vary from page to page, i.e. your page title, descriptions, keywords, content of your page etc. When you create a new webpage you have to write entire HTML code both for static and variable parts of your page. Now if you want to add a new link to the menu or if you like to change your site banner then you has to edit all HTML files you have already created. It is almost an impossible task if your website contains fifty pages or more. PHP include file is the ideal solution for this problem.

What is PHP include page statement?

PHP include statement add the content of the file to be included at the point where you put the statement. This statement takes only one argument, file name you want to include. The form of the tatement is: <?php include([filename]);?>To include a file say menu.html use the following command:<?php include(‘menu.html’);?>

If you include a text or an HTML file, content of that file will be directly added to the parent file at the point where you put the include statement. But if you include a PHP file with include statement the file to be included first compiled and then added to the parent file. If any error generated during compilation PHP will generate an error message.

How to utilize PHP include file?

To utilize PHP include file statement you keep the static parts of your HTML code in separate files, say menu.html, footer.html, top.html etc. For your convenience keep those files in a separate include directory. When you create a new webpage write your HTML code as usual but when you need to write the static part HTML code you just put PHP include file statement to add those codes. So the resulting file becomes smaller and hence easier to maintain. Also you can edit the static part code by editing only a single file.

Point to remember:

You can use PHP include page statement to include HTML or PHP file, but the parent file where you put the include statement must be a PHP file. So when saving that page use.php extension.

Advantages of PHP include page

Resulting page is smaller. So smaller web space required.As codes are divided into multiple segments so it is easier to maintain.Finally PHP is free software. So no extra cost you require to get PHP.

About the Author

This article is written by susen. You can get various useful ajax/php/my-sql script and articles from author’s website:

Leave a Reply

Your email address will not be published.