Internet Business Blog
« Previous | Home | Next »

 

Understanding Include Files

Share/Bookmark

March 27, 2007

One of the things I cover in my course Introduction to Web Site Creation is using include files to build web pages. An include file is a file that's called or included from another file. A menu, footer, or header is a good example. If your menu, footer, or header is the same on each page of your web site, instead of repeating that section of code on each page, why not have just ONE file for the menu, and one file for the header, etc. You then reference that file from the main code of your web page and it's included as if its code is part of the main page. The great thing is that when you need to change your menu, footer, or header, you only have one file to edit instead of having to edit all the pages of your web site.

Different scripting/programming languages have different syntax for including files; I'll cover PHP here.

One way to approach the initial creation of a page or web site that uses include files is to create the whole page without the include files, and then cut out the sections of code you want to put in include files. I recommend NotePad+ as a good HTML / Code editor (it's Free!).

For example, let's make a menu with two links in it; put this code in a file called incMenu.php:


Then, from the main page, index.php and/or the other pages in the web site, we'll call or Include incMenu.php. You'll put the following statement in index.php where you would normally have put the contents of the incMenu.php file (the two links in this example):


When someone browsing the Internet requests your web page, your web server's PHP engine processes your index.php file and sees the include statement (require) and gets the incMenu.php file and puts it's content into the output that's sent to the end user. In other words, the server replaces the
statement with the contents of the incMenu.php file on the fly. One thing to keep in mind if your server is a Linux/Unix server, is that capitalzation counts (it does not on Windows based servers). So if you name your include file "incMenu.php", you need to reference it from the main files (index.php for example) with the same letters capitalized, "incmenu.php" will not work, you need to use "incMenu.php".

You can use this same technique for headers, footers, sidebars, etc., any part of a page that gets repeated on multiple pages.

The one down side to using include files is that it's harder to layout and edit your pages because parts of your pages are now in more than one file. However, it can save you a huge amount of time because you only have one file to edit vs. editing every page of your web site.

Want to learn more? Get my courses Introduction to Web Site Creation which covers include files and more, and also Web Site Scripting which covers basic php scripting and forms.

Fred
About the Author

Fred Black is an experienced online business operator, programmer, web site developer, father, husband, musician, and songwriter. Visit his Internet Business Blog at: http://www.pqInternet.com.


You may reprint or distribute this article as long as you leave the content and the About the Author resource box at the end intact.


Get Free Updates! Enter your name and e-mail address to receive a short notice each time I make a new post.

First Name:

Last Name:

E-Mail Address:

E-Mail again:

NOTE: You will receive a confirmation email. You must click the link in the email to activate your free updates. Please check your spam folder(s) if you don't receive the email.


Share/Bookmark

Tip Jar: Leave a Donation

Comments: 0,   TrackBacks: 0.

Posted by Fred on March 27, 2007 | Printer-Friendly

TrackBack: http://www.pqInternet.com/Blog/mt-tb.cgi/34


Assigned Categories: Web Site Design, HTML, CSS


Related Entries:

 

 
Comments and TrackBacks 
 

 


Post A Comment




Remember personal info?




Comment Policy <--- Read the comment policy (Updated 1/13/2010).

About  Contact  Free Products Fred W. Black

Blog Feeds, EMail, etc.:

Subscribe by EMail

RSS 2.0 Feed for www.pqInternet.com.
Add to Google Toolbar

Free Updates via EMail

Receive Free Updates.

Free Products and Software.

Search

 

Link to Me!

How to Link to this Blog.

Products

Products I Use & Recommend

www.3WayLinks.Net

www.1WayLinks.Net

Free Traffic System

Wordtracker Keyword Research Tool

www.aweber.com Opt-In List Management.

1&1 Hosting

Categories

All

ClickBank

Copywriting

Free Videos

Funny

Internet Business

Internet Marketing

Life

Search Engines: SEO

Social Media

Technology

Traffic

Truth and Freedom

Web Site Design, HTML, CSS

Recent Entries

Facebook Fan Pages and Static FBML Part 3: iFrames!

Facebook Fan Pages and Static FBML Part 2

Facebook Fan Pages and Static FBML - Part 1

Texting Social Media Updates - Useful vs. Useless

Success or Failure in an Internet Business Depends on Who's Looking Back at You in the Mirror...

Bullets from God - The Greatest Copywriter of All Time?

Success is not Sticky - You Have to Hold the BALL!

Birthday Salute!

New Layout

What's the Value of a Link to SEO (Search Engine Optimization)?

Internet Business Ethics 101

Exploding Your Copy (and life) From Sissy to SEISMIC.

Long Tail Keywords

I'm a Slasher!

Start Your Own Home Internet Business with these 7 Easy Steps...

All Entries

Recently Commented On

Mozilla Thunderbird Email Client - Part 2: Corrupted Inbox

Facebook Fan Pages and Static FBML - Part 1

Long Tail Keywords

Bullets from God - The Greatest Copywriter of All Time?

Success is not Sticky - You Have to Hold the BALL!

Success or Failure in an Internet Business Depends on Who's Looking Back at You in the Mirror...

Replacing a ClickBank Vendor's Sales Page with Your Own.

Facebook Fan Pages and Static FBML Part 2

Archives

All

Blog Roll

Clayton Makepeace

Terry Dean

Ryan Healy

ProBlogger

Internet Business Resources Blog

Michel Fortin

G. Brent Riggs

Jonathan Leger

Mark J Ryan

Dr. Joe Vitale

Search Engine Journal

Friday Traffic Report

Links

Cell Phones for Soldiers

Front Street Playschool

Clebe McClary

the IconFactory

Fred Black Music

Daryl Laws Sports Performance Blog

Williams High School Booster Club

Jacob Ingle

Light Peak

EasyIRS.com

Web Hosting

My Recommended Web Hosting Service: 1&1 Hosting

Mugs, Mousepads, etc.

About this Blog...

By:Fred W. Black

Contact Information

Powered by:Movable Type 3.34.

Copyright 2006 -2010, PhaseQuest.Com.
All rights reserved.

Subscribe by EMail RSS 2.0 Feed for www.pqInternet.com.

Add to Google Toolbar
My Facebook Fan Page
Twitter
Add www.pqInternet.com, to Google. Add www.pqInternet.com, to My Yahoo! Add www.pqInternet.com, to My MSN. Subscribe to www.pqInternet.com, with Bloglines Add www.pqInternet.com, to Your Technorati Favorites! Add www.pqInternet.com, to Windows Live

rs

Some photos are by: Lee Hinshaw Photography

© Copyright 2006 - 2010 PhaseQuest, all rights reserved.

 

Get Free Updates!

Insert your name and e-mail address to receive a short notice each time I make a new post.

First Name:

Last Name:

E-Mail Address:

E-Mail again:

NOTE: You will receive a confirmation email. You must click the link in the email to activate your free updates. Please check your spam folder(s) if you don't receive the email.

*I value your privacy and will never sell, rent, giveaway, or abuse your information.