PHP/Utility Function/include once
include_once and require_once will only include a file once
//bar.php:
<?php
print "In bar\n";
?>
//index.php
<?php
include_once "bar.php";
include_once "BAR.php";
include_once "Bar.php";
?>
include_once() function verifies whether or not the file has already been included.
If it has been included, include_once() will not execute.
Otherwise, it will include the file as necessary.
Its syntax follows: include_once (file insertion_file)
Using include_once to include a file
A sample include file called add.php
<?php
function add( $x, $y ){
return $x + $y;
}
?>
<?php
include_once("add.php");
include_once("add.php");
echo add(2, 2);
?>