Home Tutorial Php PHP Variables and Includes

 
 

Share on Google+Share on Google+
PHP Variables and Includes
Posted on: January 9, 2010 at 12:00 AM
Advertisement
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.

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.

Index.php

<html>
<head>
<title>Index</title>
</head>
<body>
<?php include("header.php"); ?>
<h1>Welcome to my home page!!</h1>
<p>Hello World</p>
</body>
</html> 

The second file called header.php

<html>
<head>
<title>Header</title>
</head>
<body>
<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>

</div>
</body>
</html>

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.

Advertisement

Related Tags for PHP Variables and Includes:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: January 9, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com