Publishing System Settings Logout Login Register
A simple PHP Includes tutorial
TutorialCommentsThe AuthorReport Tutorial
Tutorial Avatar
Rating
Add to Favorites
Posted on May 25th, 2007
843 views
PHP Coding
A simple PHP includes tutorials

Hello guys and welcome to my first tutorial on pixel2life. This tutorial will be helpful to you who are learning PHP or just want an easy way to include files.

The tutorial continues on the next page!



Ok, so the code to include files are as follows:

<?php include("filelocationhere") ?> 


It is a really simple way of including a file and is one of the most common pieces of code you will find in PHP.

On the nextpage I will show you how you could use include files to make changing a webpage easier!

If you use PHP includes, the page must have the .php extension rather then .html



Ok so you have the basic HTML document:


<html>
<head>
<title>Page Title</title>
</head>

<body>
Your content here
</body>

</html>
 


Now, you can make that page a lot smaller by using PHP includes. This is how:

Put everything above the "Your content here" line into a file called header.php.

This is what should be in your header.php:


<html>
<head>
<title>Page Title</title>
</head>

<body>
 


Now put everything below the "Your content here" line into a file called footer.php.

This is what should be in your footer.php:


</body>

</html>


Now, you can change the basic HTML document to this:


<?php include("header.php") ?>
Your content here
<?php include("footer.php") ?>


If you have a really advanced template, this is makes it a lot easier to change your layout because you would update just the header.php & footer.php files and that would update all the pages.

I hope you found this tutorial useful!

Remember all pages using the include code must have the .php extension!
Dig this tutorial?
Thank the author by sending him a few P2L credits!

Send
kozine

This author is too busy writing tutorials instead of writing a personal profile!
View Full Profile Add as Friend Send PM
Pixel2Life Home Advanced Search Search Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Pixel2life Homepage Submit a Tutorial Publish a Tutorial Join our Forums P2L Marketplace Advertise on P2L P2L Website Hosting Help and FAQ Topsites Link Exchange P2L RSS Feeds P2L Sitemap Contact Us Privacy Statement Legal P2L Facebook Fanpage Follow us on Twitter P2L Studios Portal P2L Website Hosting Back to Top