Server Side Includes
Server Side Includes :
Server
side includes SSI : include() or require() are used for
inserting the content of one php file or any other file into the current php
file before the server executes it.
1.
Include()
: generates
a working incase the specified file cannot be loaded, but the script will
continue execution.
2.
Require():
generates
a fatal error, and the script will stop incase the specified file cannot be loaded.
these
two functions are used to create functions,headers,footers,or elements that
will be reused on multiple pages.
The
advantage of using server side include is you can create a standard
header,footer,or menu file for all your web pages. When the footer needs the
header needs to be uploaded, you need to update only the include file.
Include(file name)
Require(file name)
Include_once(file name)
Require_once(file name)
Note: it
is not possible to include morethan one file with the same function definition
present inside that because in a php program it is not possible to redeclare a
function.
Functions.php
<?php
Function
addNum($x=0,$y=0)
{
$res
= $x+$y;
Return
$res;
}
Function
display()
{
}
?>
India.php
<?php
Function
display($x)
{
-
- - - - - - - - - - ;
}
?>
Myapp.php
<?php
Include(‘functions.php’)
or require(‘functions.php’)
Echo “sum=”
.addName(11,22);
?>
What
is the difference between include() and include_once() ?
Includes_once statement includes and evaluates
the specified file during the execution of a script.this is a behavior similar
to the include() statements, with the only difference being that if the code
from a file has already been included, it will not be included again.
India.php
<?php
Echo “Indian tech”;
?>
Ssitest.php
<?php
Include(‘india.php’);
/*include(‘india.php’);
Include(‘india.php’);
*/
Include_once(‘india.php’);
Include_once(‘india.php’);
?>
0 comments:
Post a Comment