One of the main advantages to using PHP is the use of INCLUDES. With HTML web pages, to make a change to one menu option will involve you editting every single page. This can be very time consuming and nowadays something that will happen on a regular basis.
Using pHP and an INCLUDE you can do this just by having a menu in a seperate file and including it into the main page where you would like the menu to appear. My tutorials menu on the side is in an include, and so is the top of the page as well as the footer part.
You can also have a page with just variables that you will use every page and this can be used in an include.
To Use an Include just use the following :-
<?php
include('filename.php');
?>
As an example i will show you how to include and display a varible from a seperate file.
The include file : -
<?php
$variable1 = "hello" ;
$variable2 = "Tommy" ;
$variable3 = "I Hope Your Day Is Good" ;
?>
That file is saved as ‘variables.php’
The Main File : -
<?php
include(‘variables.php’) ;
echo $variable1.’ ‘.$variable2.’ ‘.$variable3 ;
?>
The Outcome of the above is : -
hello tommy i hope your day is good.
I hope this give you a good insight into the advantages of using includes.
