<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>include_once</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.require-once.html">require_once</a></div> <div class="next" style="text-align: right; float: right;"><a href="control-structures.goto.html">goto</a></div> <div class="up"><a href="language.control-structures.html">Control Structures</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.include-once" class="sect1"> <h2 class="title">include_once</h2> <p class="verinfo">(PHP 4, PHP 5)</p> <p class="para"> The <em>include_once</em> statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the <span class="function"><a href="function.include.html" class="function">include</a></span> 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"> <em>include_once</em> 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 <span class="function"><a href="function.include.html" class="function">include</a></span> documentation for information about how this function works. </p> <p class="para"> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> With PHP 4, <em>_once</em> functionality differs with case-insensitive operating systems (like Windows) so for example: <div class="example" id="example-146"> <p><strong>Example #1 <em>include_once</em> with a case insensitive OS in PHP 4</strong></p> <div class="example-contents"> <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> <p class="para"> 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. </p> </p></blockquote> </p> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.require-once.html">require_once</a></div> <div class="next" style="text-align: right; float: right;"><a href="control-structures.goto.html">goto</a></div> <div class="up"><a href="language.control-structures.html">Control Structures</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>