PHP Include Function Tutorial | Coding Tag
×

PHP Include Function

4350

PHP is a well known name in the field of website development. It is free and hence widely used by the web developers. PHP is the combination of several functions.

There is one function in PHP that every web developer must know that is the include function. Whether you are a newbie or experienced in PHP, it is essential and vital to know for anyone who needs to develop a website. Knowing this function will create your web development much easier and faster.

Include is very simple to use in a web page. It needs one argument which is a string of the location of the file to comprise.

To apply this function in your web page, see below the format:

$header_file = "header.php";

include($header_file); // Includes the contents of the header file.

include("navigation.php"); // Includes the contents of the navigation file.

PHP Include Example:

<?php
include 'header.php';
?>
<?php
include 'footer.php';
?>

The PHP include function is very beneficial because it comprises the contents of another file which placed in another location. You may not understand this at first, but this permits you to have a file that is just the header, the footer, or the navigation of your web page.

This way, whenever you require modifying it, instead of updating each file, you just modify the one file.



Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments