downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

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">&lt;?php<br /></span><span style="color: #007700">include_once&nbsp;</span><span style="color: #DD0000">"a.php"</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;this&nbsp;will&nbsp;include&nbsp;a.php<br /></span><span style="color: #007700">include_once&nbsp;</span><span style="color: #DD0000">"A.php"</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;this&nbsp;will&nbsp;include&nbsp;a.php&nbsp;again!&nbsp;(PHP&nbsp;4&nbsp;only)<br /></span><span style="color: #0000BB">?&gt;</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(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites