Source of: /manual/en/function.include-once.php
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/language.control-structures.inc";
$setup = array (
'home' =>
array (
0 => 'index.php',
1 => 'PHP Manual',
),
'head' =>
array (
0 => 'UTF-8',
1 => 'en',
),
'this' =>
array (
0 => 'function.include-once.php',
1 => 'include_once',
),
'up' =>
array (
0 => 'language.control-structures.php',
1 => 'Control Structures',
),
'prev' =>
array (
0 => 'function.require-once.php',
1 => 'require_once',
),
'next' =>
array (
0 => 'control-structures.goto.php',
1 => 'goto',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<div id="function.include-once" class="sect1">
<h2 class="title"><b>include_once()</b></h2>
<p class="para">
The <b>include_once()</b> statement includes and evaluates
the specified file during the execution of the script.
This is a behavior similar to the <a href="function.include.php" class="function">include()</a> statement,
with the only difference being that if the code from a file has already
been included, it will not be included again. As the name suggests,
it will be included just once.
</p>
<p class="para">
<b>include_once()</b> may be used in cases where
the same file might be included and evaluated more than once during a
particular execution of a script, so in this case it may help avoid
problems such as function redefinitions, variable value reassignments, etc.
</p>
<p class="para">
See the <a href="function.include.php" class="function">include()</a> documentation for information about
how this function works.
</p>
<p class="para">
</p><blockquote><p><b class="note">Note</b>:
With PHP 4, <i>_once</i> functionality differs with case-insensitive
operating systems (like Windows) so for example:
</p><div class="example">
<p><b>Example #1 <b>include_once()</b> with a case insensitive OS in PHP 4</b></p>
<div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /></span><span style="color: #007700">include_once </span><span style="color: #DD0000">"a.php"</span><span style="color: #007700">; </span><span style="color: #FF8000">// this will include a.php<br /></span><span style="color: #007700">include_once </span><span style="color: #DD0000">"A.php"</span><span style="color: #007700">; </span><span style="color: #FF8000">// this will include a.php again! (PHP 4 only)<br /></span><span style="color: #0000BB">?></span>
</span>
</code></div>
</div>
</div><p>
<br />
This behaviour changed in PHP 5, so for example with Windows the path is normalized first so that
<var class="filename">C:\PROGRA~1\A.php</var> is realized the same as
<var class="filename">C:\Program Files\a.php</var> and the file is included just once.
<br />
</p></blockquote><p>
</p>
</div><?php manual_footer(); ?>