PHP Include( ) Function
Suppose, we are making a project and the project is big enough that all the work cannot be done in one file or application and it will be complicated. So, i suggest you to divide your project into different files. It will make your file reusable or more readable and it can be happen through only Include( ) Function.
Include( ) Function will be helpful for your project. With the help of include function you can insert one php file into another file or you can use that file unlimited time in your project. For example : You are making a website for your company and you divide the whole project into header file, menu file, content file or footer file. So, you can use these in every page according to your requirement. Let see the small example :
The first file called Index.php. Here, we include all the php files.
<?php include("header.php"); ?>
<h1>Welcome to my home page!!</h1>
The second file called header.php
<div width="100%" height="100px" align="center" >
<h1 style="background-color:#000000; font-family:Tahoma; font-size=16; color:red; align:center; width:100% height:100px; line-height:100px">Welcome to our Page !!</h1>
Now, you can run the file and you can see how it looks and how it effects to your index file. In the same way you can use the above mentioned all the file.
Posted on: January 9, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles