Register|Login

Have a question? Click here to ask the community.

Tutorial 8 – Include

| In: 8. Include | 16,187 views

Video Tutorial

Part 1:


Part 2:


Video Source Code

index.php File

1
2
3
4
5
6
7
8
9
10
11
12
13
<html>
<body>
 
<?php
include("header.php"); // include header content
?>
Welcome To The Candy Shop <br>
<?php
include("footer.php"); // include footer content
?>
 
</body>
</html>

header.php File

1
2
3
4
5
6
7
8
<!-- Header Content -->
 
<a href="index.php">Home</a> |
<a href="products.php">Products</a> |
<a href="aboutUs.php">About Us</a> |
<a href="contactUs.php">Contact Us</a> |<br>
 
<!-- End Header Content -->

footer.php File

1
2
3
4
5
<!-- Footer Content -->
 
Copyright © 2010 TheCandyShop.com
 
<!-- End Footer Content -->

products.php File

1
2
3
4
5
6
7
8
9
10
11
12
13
<html>
<body>
 
<?php
include("header.php"); // include header content
?>
List of our products <br>
<?php
include("footer.php"); // include footer content
?>
 
</body>
</html>

aboutUs.php File

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<html>
<body>
 
<?php
include("header.php"); // include header content
?>
About Us...<br>
 
<?php
include("footer.php"); // include footer content
?>
 
</body>
</html>

contactUs.php File

1
2
3
4
5
6
7
8
9
10
11
12
13
<html>
<body>
 
<?php
include("header.php"); // include header content
?>
Contact Us Page..<br>
<?php
include("footer.php"); // include footer content
?>
 
</body>
</html>



2 Responses to Tutorial 8 – Include

Avatar

Faixan KHan

August 17th, 2011 at 6:53 am

It really helped me………….Thanks alot…….. but i have a question that how can we put images in header through include commands…………… i want to say that how a Template can be made through include function.??? Please reply if any body knows. Thanks.

Avatar

Robert Smith

January 22nd, 2012 at 5:50 pm

You can include a file that contains an image if you want. Simply place the correct HTML tag for an image in the file you are including, and the image will be displayed on the page that is using the include command.

Comment Form

You must be logged in to post a comment.