Function in PHP

Include Function in PHP

Include function in PHP copy all the contents of one PHP file in other PHP file. Once you include a file then all the variable of include file inherits the variable scope of the line on which the include occurs and can be used after this line. Include function is very help full when you want to use same type of contents in more then pages in the same way.
For example if you have a file which have some content and you want to use these content in other file then you have two way first you copy the content and past in new file and other method is use include function. with including all the content of that file is become part of new file. This will help developers to make it easy to change the layout of complete website with minimal effort. If there is any change required then instead of changing thousand of files just change included file.
For example
if you have a common menu for your web site then make a file which contain some content of you menu and then just include on the top of you every file.
For Example if your menu file is menu.php then
when you want to include this file in new file then your code will be:


<html>

<body>

<?php

include "menu.php" ;

?>
<p> from this point new file begin </p>

</bod>

</html>