PHP/Utility Function/include once
include_once and require_once will only include a file once
<source lang="html4strict">
//bar.php:
<?php print "In bar\n"; ?>
//index.php
<?php include_once "bar.php"; include_once "BAR.php"; include_once "Bar.php"; ?> </source>
include_once() function verifies whether or not the file has already been included.
<source lang="html4strict">
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)
</source>
Using include_once to include a file
<source lang="html4strict">
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); ?>
</source>