Difference between include and include_once in php
Posted by Raj
Difference between include and include_once in php
All these functions include and include_once are used to include the files in the php page.
PHP include() Function:
If the specified file is not available ,the include() function generates a warning,and executes the
remaining code.
Example:
<?php
include("test.php");
?>
PHP include_once() Function:
The include_once() statement includes and evaluates the specified file during the execution of the script. This is similar to the include() statement,with the only difference being that if the file has already been included, it will not be included again.the include_once() function generates a warning.
Example:
<?php
include_once("test.php"); //will work.
?>
All these functions include and include_once are used to include the files in the php page.
PHP include() Function:
If the specified file is not available ,the include() function generates a warning,and executes the
remaining code.
Example:
<?php
include("test.php");
?>
PHP include_once() Function:
The include_once() statement includes and evaluates the specified file during the execution of the script. This is similar to the include() statement,with the only difference being that if the file has already been included, it will not be included again.the include_once() function generates a warning.
Example:
<?php
include_once("test.php"); //will work.
?>
This entry was posted on October 4, 2009 at 12:14 pm, and is filed under
add file,
difference,
include,
include file in php,
include_once,
PHP,
PHP interview questions and answers
.You can leave a response, or trackback from your own site.