Tutorial

Click on thumbnailed images to enlarge

PHP Includes
This tutorial will hopefully be helpful so that you can use a .php [.php?/.php?abcdefghijklmnopqrstuvwxyz] extensions on your page! PHP Files are like most other files... such as HTM(L) files, except in most cases, it's a lot easier to change themes/skins. Using a .php extension includes three files.

Your first file is: header.php, where you will enter all your "header" stuff. Anything that includes...

<html><head>
<title>YOUR TITLE</title>

CSS

HEADER, INCLUDING TOP IMAGE, ETC.

</head>
<body>



Now, the next file is the footer.php file which includes any of the things you would like to include at the end of the page. Including: previous and next paginations, copyright warnings, etc. It would most likely include the following...

(/div)

</body>
</html>


The last file is a "variable" file - as i like to call it. Because, it's the rest of your files. It's your index.php file, and any other file that contains content. Include your text/pics in these files.

Okay, now that you know what the files are... let's get to what you have to do!



Your Header
01.Open up your text editor, like notepad.
02.Include this in your text editor...

<html><head>
<title>YOUR TITLE</title>

<link rel=stylesheet href="FILE OF YOUR CSS.css"
type="text/css"></a>


HEADER, INCLUDING TOP IMAGE, ETC.

</head>
<body>


03.Save the file and save it as header.php



Your Footer
01.Open a new page and add the following to it...

ANY FOOTER STUFF

</body>
</html>


02.Save this file as footer.php



Your Content
01.Get a new page, or your existing content pages, and add the following codes into them...

<?include("header.php");?>
ALL THE CONTENT GOES HERE: TEXT/PICS/ETC.
<?include("footer.php");?>



02.Save this file as the existing name, or the name of a page you want it to be. Make sure to include .php at the end, instead of .html, .htm, .txt, or .shtml!!!!!



The Rest
Upload all these files onto your web site. Okay, you must change your existing files to .php and you must take off all of the header stuff on it & footer stuff too. Sorry about that... but believe me: even if you are using iframes: change to PHP because it's a lot easier! Also, MAKE SURE to change the extensions to .php and the extensions to the links to your pages to .php or this will not work!



Don't Understand?
Okay, think of any file as a sandwich. You've got the bread on top, the filling in the middle, and then another slice of bread on the bottom.

Your header is the top bread.
Your content file is the filling.
& You footer is the bottom bread.

Let's say that this is your file.

<html><head>
<title>My Page</title>

<link rel=stylesheet href="style.css"
type="text/css"></a>

<div class="whole">
<center><img src=head.png></center>

<div class="navi">
<a href="index.php">Main</a><BR>
<a href="me.php">All About Me</a><BR>
<a href="visit.php">The Visitors</a><BR>
<a href="pics.php">My Pictures</a>
</div>
</head>
<body>
<div class="main">
Hello, and welcome to my page.
Please enjoy yourself here!
</body>
</html>


Your header.php file would be...

<html><head>
<title>My Page</title>

<link rel=stylesheet href="style.css"
type="text/css"></a>

<div class="whole">
<center><img src=head.png></center>

<div class="navi">
<a href="index.php">Main</a><BR>
<a href="me.php">All About Me</a><BR>
<a href="visit.php">The Visitors</a><BR>
<a href="pics.php">My Pictures</a>
</div>
</head>
<body>
<div class="main">



Your X.php would be... (X=ANY PAGE)

Hello, and welcome to my page.
Please enjoy yourself here!



And your footer.php file would be...

</body>
</html>


Hopefully this tutorial helped a lot!

Tutorial Comments

Showing latest 5 of 5 comments

Just a note, you don't use PHP instead of HTML. With PHP includes you're still using HTML, you're just using PHP to include your header & footer, which, of course, are coded using HTML.

By paintedskies on Mar 24, 2008 3:23 pm

QUOTE(TheSpoon @ Aug 3 2006, 2:59 AM) [snapback]2207040[/snapback]thanks so much! one question thoughfor the header, do you include the sidebar?Yes. Some people also include the header in the footer, i dunno why, i guess because of where th

By thembc on Aug 4, 2006 1:34 pm

thanks so much! one question thoughfor the header, do you include the sidebar?

By TheSpoon on Aug 3, 2006 2:59 am

I must get on using this. Thank you!

By Kathleen on Aug 2, 2006 7:36 am

wow someone actually wrote this tutorial!!!i give you props.i <3 php.

By RCcola on Aug 1, 2006 11:03 pm

Tutorial Details

Author thembc View profile
Submitted on Jul 29, 2006
Page views 6,063
Favorites 8
Comments 5