Welcome to Egypt Forums Mark forums read | Egypt Main Page
Egypt Forums
Arabic Movies



Classes & Source Code Thread, Using PHP include() – Make things easy for yourself! in PHP; Using PHP include() – Make things easy for yourself! The PHP include() statement can really help when it comes to ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=6985


Reply
LinkBack Thread Tools Display Modes
Using PHP include() – Make things easy for yourself!
 
 
The God Father
Developer's Avatar

Reply With Quote
 
Join Date: Jul 2008
Location: NDC
Posts: 5,425
04-12-2008, 04:13 AM
 
Using PHP include() – Make things easy for yourself!

The PHP include() statement can really help when it comes to editing site layout
Imagine a static site with 40 pages all with the navigation menu hard-coded into all 40 pages. What happens when more links need to be added? ANSWER: Open all 40 files and change the links manually! Not if you use the PHP include statement!

Basic Static PHP file:
<ul>
<li id="nav1">Home</li>
<li id="nav2">Page1</li>
<li id="nav3">Page2</li>
<li id="nav4">Page3</li>
<li id="nav5">Contact</li>
</ul>
<h1>Welcome to my site</h1>
Fig 1.1 – Navigation Hard-Coded into PHP file If you used the same layout structure as Fig 1.1 for every page in your site then any change to the navigation bar will need to be changed across EVERY page
The PHP include statement allows you to put the navigation menu into a separate file such as Fig 1.2 below:
<ul>
<li id="nav1">Home</li>
<li id="nav2">Page1</li>
<li id="nav3">Page2</li>
<li id="nav4">Page3</li>
<li id="nav5">Contact</li>
</ul>
Fig 1.2 – navigation.php You then ‘include’ the navigation.php in any page where you want the navigation menu to appear by using this very small piece of PHP code:

Fig 1.3 – The PHP include statement PHP include statement implementation:


<h1>Welcome to my site</h1>
Fig 1.4 – How to implement the PHP include() You could put a lot more than just the navigation menu into a separate ‘include’ file.
PHP include allows you to split your site into much smaller and manageable chunks. It is also a form of ‘future-proofing’ your site, meaning that it would be much easier to change your site design when necessary.
Look at the possibilities:
Egypt.Com EnForumPHP Include () - Possibilities

A ‘real-life’ example from of the sites in my portfolio where I have used the PHP include statement a lot:




<img src="images/home2.jpg" alt="" />

Welcome to *****



Real Life example of the include statement in action!
__________________
I Love Walking In The Rain Cuz Nobody Know I'm Crying !!
 
 
 
Reply

Classes & Source Code Thread, Using PHP include() – Make things easy for yourself! in PHP; Using PHP include() – Make things easy for yourself! The PHP include() statement can really help when it comes to ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=6985


Bookmarks

Tags
easy, include, make, php, things


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How To Include A Custom Template Via Plugins Developer Articles 0 16-11-2008 07:23 PM
Climate bill to include planes Tamer News 0 29-10-2008 03:48 PM
The Worst Things You Can Ever Do(tm) Developer Articles 0 07-10-2008 02:32 PM
Exclusive Make Joomla Templates in 5 Easy Steps Developer Web Development 2 03-07-2008 02:46 AM
50 most important things the_crazy_zende User Events 4 19-09-2007 01:06 PM