Go Back   Site Owners Forums - Webmaster Forums > Web Programming > Programming General

Notices


Reply
 
Thread Tools Rate Thread Display Modes
Old 05-10-2012, 11:56 AM   #1
leox123
Registered User
 
Join Date: May 2012
Posts: 4
Post Save time using the PHP include Function <?php include

One of the main problems faced by webmasters is saving time when it comes to creating websites. When starting a website, one may choose to create a navigation menu like the following to link to each page:

Code:
<a href="http://www.yoursite.com/index.htm">Home</a> - 

<a href="http://www.yoursite.com/about.htm">About Us</a> - 

<a href="http://www.yoursite.com/links.htm">Links</a> - 

<a href="http://www.yoursite.com/contact.htm">Contact Us</a>
Which looks like: Home About UsLinks Contact Us

So now, you have your 4 pages - and all is well. But, as the site expands you need to integrate a forum - which leaves you with 4 pages to update. No problem at all... But supposing the site had 100+ pages! That would be a very monotonous time consuming job.

This is where we bring in the php include command to really speed things up!

Create just the navigation menu on its own, and rename all of your pages to .php

In this case, the navigation menu will look like this:

Quote:
<a href="http://www.yoursite.com/index.php">Home</a> -

<a href="http://www.yoursite.com/about.php">About Us</a> -

<a href="http://www.yoursite.com/links.php">Links</a> -

<a href="http://www.yoursite.com/contact.php">Contact Us</a>
Which looks like: HomeAbout UsLinksContact Us

Save this file as "menu.inc" as we will be including it elsewhere - hence the .inc extension.

Now, open up your .php pages that the menu links to, and simply add the following code at the very top, to include the navigational menu on the pages:

<?php include("menu.inc"); ?>

The code is telling the php page, to "include" the menu.inc file - and it does!

Once this has been added, any changes in the menu.inc file are reflected across the whole site making updating a lot easier!

Why stop at menus? This can be utilised for adverts, footers, headers, templates and much much more!
Back to top
__________________
Make Money Online by locking links - bee4.biz/?ref=17978
leox123 is offline   Reply With Quote

Old 05-17-2012, 11:20 PM   #2
isoconsultantgm
Registered User
 
Join Date: May 2012
Posts: 117
very nice post thanks for sharing this valuable information.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
||
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
isoconsultantgm is offline   Reply With Quote
Reply


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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Importance of Php Development for Web Development tech.biztech Programming General 35 11-22-2019 12:37 AM
Php tonybrown2387 PHP / mySQL 16 08-01-2014 10:04 PM
The best source of learn PHP easily at home. chikkiarora Programming General 11 02-10-2013 02:18 AM
PHP is an HTML-embedded scripting idiom tommydenis PHP / mySQL 14 06-04-2012 02:15 AM
Are you aware of the fact that PHP programming is the most widely used one? johnrichards774 PHP / mySQL 3 02-07-2012 05:41 AM


All times are GMT -7. The time now is 10:28 AM.


Powered by vBulletin Copyright © 2020 vBulletin Solutions, Inc.