icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » Search Me! » [Article] PHP Includes

Search Me! Lots of information is found in this board. You can also ask general questions here if you'd like! This is the last stop on Surmunity.

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old March 17th, 2008, 3:23 PM   #1 (permalink)
URB4N 5K1LLZ
Super #1
 
Roxy's Avatar
 
Joined in Sep 2005
Lives in Orlando, FL
Hosted on SH63
2,660 posts
Gave thanks: 81
Thanked 128 times
[Article] PHP Includes

As you know, editing a website and it's pages can sometimes be a hassle on its own. No worries, we have a very easy-to-use solution for you. PHP Includes.

Using includes can help you tons if you have a large website with many pages to edit. Just think, you have over 100 pages worth of content, with a header and footer the same on every page, sadly when you have a new link to enter into either of these, you need to edit each and every one of those 100 pages separately. Sounds pretty gruesome huh? Well not anymore, using includes can help you go from editing 100 pages to only editing one or two files!

How Does it Work?
Usually you have a main header and footer design that never changes for each page, yet you constantly are editing it to add either new links or other things. This can very time consuming, so in order to cut down that time, seperate the header and footer into their own respective files. Make sure to save them with .php file format. (ex: header.php - footer.php)

Once you have done this, delete them from the main page you took them from, leaving only the main content, or body of the page. Replace the deleted text with the following code:

PHP Code:
<?php include("filename.php"); ?>
where "filename.php" will be header.php or footer.php. After you have done this make sure to save the page with the .php file format also.

Upload the pages and see the changes! Everything will look exactly the same as if you would have never changed anything! Now you can easily edit your header and footer with only two files for over 100 pages!

This code can also apply to other files that you'd like to include in certain areas on your website, just remember to always have each file/page end in the .php format for it to work!

Good luck!
__________________
Roxanne


Urban Roxy -Personal Blog
SH63 - the best darn shared server!
Roxy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old March 17th, 2008, 3:44 PM   #2 (permalink)
Surpass Developer
Excelling Contributor
 
Mark's Avatar
 
Joined in Jan 2004
Lives in Florida
Hosted on decc.surpasshosting.com
520 posts
Gave thanks: 21
Thanked 78 times
Remember to never use variables inside includes unless the variable is properly sanitized
__________________
Mark
Surpass Hosting Developer
sɹnoʎ uɐɥʇ ɹǝʇʇǝq sı bıs ʎɯ
Mark is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old March 17th, 2008, 3:55 PM   #3 (permalink)
URB4N 5K1LLZ
Super #1
 
Roxy's Avatar
 
Joined in Sep 2005
Lives in Orlando, FL
Hosted on SH63
2,660 posts
Gave thanks: 81
Thanked 128 times
Thanks Mark.
__________________
Roxanne


Urban Roxy -Personal Blog
SH63 - the best darn shared server!
Roxy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old March 17th, 2008, 6:22 PM   #4 (permalink)
H
after g, before i
Resident.
 
H's Avatar
 
Joined in Jul 2004
Lives in N,BC,CA
8,089 posts
Gave thanks: 48
Thanked 131 times
If you're doing a lot of nested includes, you might want to use include_once. It'd be pretty poor design to run into the problem, but it doesn't really hurt.
H is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old March 17th, 2008, 6:31 PM   #5 (permalink)
URB4N 5K1LLZ
Super #1
 
Roxy's Avatar
 
Joined in Sep 2005
Lives in Orlando, FL
Hosted on SH63
2,660 posts
Gave thanks: 81
Thanked 128 times
Quote:
Originally Posted by H View Post
If you're doing a lot of nested includes, you might want to use include_once. It'd be pretty poor design to run into the problem, but it doesn't really hurt.
This is true.
__________________
Roxanne


Urban Roxy -Personal Blog
SH63 - the best darn shared server!
Roxy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 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