Control Structures


include_once

The include_once statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include statement, with the only difference being that if the code from a file has already been included, it will not be included again.

Syntax Description
include_once filename; includes the specified file into current script
filename can be referenced by a variable
filename is case-sensitive
test.php
<?php
echo "Hello\r\n";
?>
init.php
<?php
include "test.php";       // include test.php
include "test.php";       // include test.php again
include_once "test.php";  // not include test.php
?>
[result]  
Hello
Hello