Basic PHP Includes

eukhost 468x60

Basic PHP Includes

php

120x600

Lets say you have a Web site with 10 or so pages, and you want to update the navigation. You don’t want the hassle of updating every single page. That’s where includes come in handy.

Your basic include will look like this.

< ?php include ( ‘includes/navigation.php’ ); ?>

That’s it! What I typically do is design a page as usual, then begin breaking sections up into includes. To use this effectively:

1) Find sections or tables that will repeat throughout the site.
2) Cut the section of code out and paste it into another file.
3) Save this file into an includes folder.
4) Where the original section was, insert your PHP inclue code, referencing the file name.

Let’s say I want to use the highlighted code on multiple pages.

< table>
< tr>
< td>
This table will be on every page.
< /td>
< /tr>
< /table>
< table>
< tr>
< td>
This is some other content.
< /td>
< /tr>
< /table>

I’ll include it like this.

< ?php include ( ‘includes/table.php’ ); ?>
< table>
< tr>
< td>
This is some other content.
< /td>
< /tr>
< /table>

Now if I change table.php later, it will change on every page automatically. It’s just like using image tags, but instead of image files, you are including pieces of html. This can save you hours and hours.

Alan Hettinger is a freelance designer available for print, web, and multimedia projects.

euk 728x90 2

VN:F [1.9.17_1161]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)

Related Posts:



Online 24X7 Chat Support
 
 
Telephone
Toll Free
Online chat
 
Online 24X7 Email Support
 
Emails
 
 
 
Support
Support email
sales
Sales email
 
Billing
Billing email
 
   
Latest Tutorials & Articles (Updated Daily)
http://blog.eukhost.com
  Forums :
http://www.eukhost.com/forums/