Total members 11894 |It is currently Fri Nov 22, 2024 1:34 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Can you imagine , write a pace of code once and use it many times .Any changes in this code you will only change in one file .it will be a nightmare if you duplicated the code in every place you wanted to use it .You have to go all over these code parts and do your update .you can do this in PHP by including the file you want to use.

suppose you are using an mean bar that you want to be visible in all your site pages for example
header.php
Code:
<html>
<body>
<a href="http://www.codemiles.com/index.php">Home</a> -
<a href="http://www.codemiles.com/about.php">About Us</a> -
<a href="http://www.codemiles.com/links.php">Links</a> -
<a href="http://www.codemiles.com/contact.php">Contact Us</a> 

and the output of this is :
Code:
Home - About Us - Links - Contact Us

Put links for sure, suppose now you want to add these links in your page .you will do the following :

index.php content is :
Code:

<?php include("header.php"); ?>
<p>My site home page !</p>
</body>
</html>


the HTML code that will be generated of index.php is :
Code:
<html>
<body>
<a href="http://www.codemiles.com/index.php">Home</a> -
<a href="http://www.codemiles.com/about.php">About Us</a> -
<a href="http://www.codemiles.com/links.php">Links</a> -
<a href="http://www.codemiles.com/contact.php">Contact Us</a>
<p>My site home page !</p>
</body>
</html>


making header and footer files for your site is a well known technique in web design.

hope this topic help you , thanks



_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : PHP Include
 Require vs Include in php     -  
 Using include() Within a Loop     -  
 Using include function     -  
 get include path     -  
 jsp include directive not working     -  



Topic Tags

PHP Functions
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com