18 – PHP Include

0
59

This tutorial is all about PHP Include.
Even though you don’t have enough much understanding about the details of PHP, you have nothing to worry about because you can save yourself with the use of PHP include command.

 

Include command is used to get the file name and insert that file into the script that provide an include command. This method has the ability to lessen your working load and when updating you don’t have to update all the pages because you can simply make it on one page. For instance, a navigation file.

 

See Examples Below:

  • Create a file and name it “navigation.php“. After that, do the following codes as follows.

navigation.php Code:

<html>
<body>
<a href="index.php">Home</a> - 
<a href="about.php">About Us</a> - 
<a href="contact.php">Contact Us</a> <br />
  • Create a file and name it “index.php”. After that, do the following codes as follows.

index.php Code:

<?php include("navigation.php"); ?>
<p>This is the index page!</p>
</body>
</html>
  • Create a file and name it “about.php“. After that, do the following codes as follows.

about.php Code:

<?php include("navigation.php"); ?>
<p>This is the about page!</p>
</body>
</html>
  • Create a file and name it “about.php“. After that, do the following codes as follows.

contact.php Code:

<?php include("navigation.php"); ?>
<p>This is the contact page!</p>
</body>
</html>

Output:

 

HomeAbout Us – Contact Us

 

Readers might read also:

 

 

Facebook Comments
(Visited 84 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here