ITSourceCode.com

We Exist to Provide 100% Free Source Code and Tutorials

Custom Search

18 – 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

 

Facebook Comments

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked *

ITSourceCode.com © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!