| PHP include page statement is an extremely useful | | | | If you include a text or an HTML file, content of that |
| statement to build your Web pages. If you are very | | | | file will be directly added to the parent file at the |
| new in PHP or even don't know it at all, you can also | | | | point where you put the include statement. But if |
| utilize this statement to manage your website. | | | | you include a PHP file with include statement the file |
| Logically you can divide HTML code of a web page | | | | to be included first compiled and then added to the |
| into multiple segments. Some of those are static | | | | parent file. If any error generated during compilation |
| parts and others are variable parts. Static parts are | | | | PHP will generate an error message. |
| those which do not change from page to page, i.e. | | | | How to utilize PHP include file? |
| top part of your page where you put your site name | | | | To utilize include file statement you keep the static |
| and banner, menu, bottom part of your page where | | | | parts of your HTML code in separate files, say |
| you put copyright notice, etc. Variable parts of your | | | | menu.html, footer.html, top.html etc. For your |
| page are the elements which vary from page to | | | | convenience keep those files in a separate include |
| page, i.e. your page title, descriptions, keywords, | | | | directory. When you create a new web page write |
| content of your page etc. When you create a new | | | | your HTML code as usual but when you need to |
| web page you have to write entire HTML code both | | | | write the static part HTML code you just put PHP |
| for static and variable parts of your page. Now if you | | | | include file statement to add those codes. So the |
| want to add a new link to the menu or if you like to | | | | resulting file becomes smaller and hence easier to |
| change your site banner then you has to edit all | | | | maintain. Also you can edit the static part code by |
| HTML files you have already created. It is almost an | | | | editing only a single file. |
| impossible task if your website contains fifty pages | | | | Point to remember: You can use include page |
| or more. PHP include file is the ideal solution for this | | | | statement to include HTML or PHP file, but the |
| problem. | | | | parent file where you put the include statement must |
| What is PHP include page statement? | | | | be a PHP file. So when saving that page use .php |
| PHP include statement adds the content of the file to | | | | extension. |
| be included at the point where you put this | | | | Advantages of PHP include page |
| statement. This statement takes only one argument, | | | | |
| file name you want to include. The form of the | | | | 1. Resulting page is smaller. So smaller web space |
| statement is: | | | | required. |
| | | | 2. As codes are divided into multiple segments so it is |
| To include a file say menu.html use the following | | | | easier to maintain. Finally PHP is free software. So no |
| command: | | | | extra cost you require to get PHP. |
| | | | |