This command is used to help you in editing your menu or web site. If you like to add something in your website, then there is no need to make link of that on all web pages. You have to use “include command” in the menu and all the new material will into use.
If we like to use a file for all our web pages, then it should have .php extention. We can save it as mymenu.php.
Code for mymenu.php
<a href="http://www.instance.com/index.php">Main Page</a> -
<a href="http://www.instance.com/about.php">Know Us</a> -
<a href="http://www.instance.com/links.php">Associations</a> -
<a href="http://www.instance.com/contact.php">Make contact with us</a> <br />
The file mymenu.php is saved. Make another file “catalog.php” and save it in the same path. It will give us benefit of adding in our menu, by using a time saving command of Include
<?php include("mymenu.php"); ?>
<p>This main page has a menu which saves my time while adding new pages!</p>
Main Page – Know Us – Associations – Make contact with us
The main page has a menu which saves my time while adding new pages!
If you have more than 20 pages then it will be a great problem for you to make change on all files. It will be a time consuming process. You will get bored with it. But “Include command” can make it easy. You have to just mymenu.php and the link will come on all pages.
The output for Viewers:
If the viewers have to check the basis of catalog.php, then what will they see?
Viewers will see the source of catalog.php as:
<a href="catalog.php">Main Page</a> -
<a href="Know us.php">Know us</a> -
<a href="asociations.php">Associations</a> -
<a href="make contact with us.php">Make contact with us</a> <br />
<p>This main page as menu which saves my time while adding new pages!</p>
Here, the viewer will be able to see the codes of HTML as one extensive line.
The function of include is to copy all the text from the file. It pastes the data into a file. This command is helpful when there are many web pages. Most of the developers of web pages use the command of include. Echo was not used in PHP as function. Similarly, Include is used as constructive of a language. It can not be used as a function.
The other lectures will be about required command. It has been seen that for PHP, require command is much better then include command.