<HTML ><HEAD ><TITLE >include_once</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Control Structures" HREF="control-structures.html"><LINK REL="PREVIOUS" TITLE="require_once" HREF="function.require-once.html"><LINK REL="NEXT" TITLE="Functions" HREF="functions.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="sect1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.require-once.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Chapter 12. Control Structures</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="functions.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="function.include-once" ></A ><A HREF="function.include-once.html" ><B CLASS="function" >include_once()</B ></A ></H1 ><P > The <A HREF="function.include-once.html" ><B CLASS="function" >include_once()</B ></A > statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the <A HREF="function.include.html" ><B CLASS="function" >include()</B ></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 > <A HREF="function.include-once.html" ><B CLASS="function" >include_once()</B ></A > should be used in cases where the same file might be included and evaluated more than once during a particular execution of a script, and you want to be sure that it is included exactly once to avoid problems with function redefinitions, variable value reassignments, etc. </P ><P > For more examples on using <A HREF="function.require-once.html" ><B CLASS="function" >require_once()</B ></A > and <A HREF="function.include-once.html" ><B CLASS="function" >include_once()</B ></A >, look at the <A HREF="http://pear.php.net/" TARGET="_top" >PEAR</A > code included in the latest PHP source code distributions. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </B > <A HREF="function.include-once.html" ><B CLASS="function" >include_once()</B ></A > was added in PHP 4.0.1pl2 </P ></BLOCKQUOTE ></DIV ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </B > Be aware, that the behaviour of <A HREF="function.include-once.html" ><B CLASS="function" >include_once()</B ></A > and <A HREF="function.require-once.html" ><B CLASS="function" >require_once()</B ></A > may not be what you expect on a non case sensitive operating system (such as Windows). <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN5292" ></A ><P ><B >Example 12-9. <A HREF="function.include-once.html" ><B CLASS="function" >include_once()</B ></A > is case sensitive</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" >include_once("a.php"); // this will include a.php include_once("A.php"); // this will include a.php again on Windows!</PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></BLOCKQUOTE ></DIV ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >Warning</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P >Windows versions of <TT CLASS="literal" >PHP</TT > prior to PHP 4.3 do not support accessing remote files via this function, even if <A HREF="ref.filesystem.html#ini.allow-url-fopen" >allow_url_fopen</A > is enabled. </P ></TD ></TR ></TABLE ></DIV ><P > See also <A HREF="function.include.html" ><B CLASS="function" >include()</B ></A >, <A HREF="function.require.html" ><B CLASS="function" >require()</B ></A >, <A HREF="function.require-once.html" ><B CLASS="function" >require_once()</B ></A >, <A HREF="function.get-required-files.html" ><B CLASS="function" >get_required_files()</B ></A >, <A HREF="function.get-included-files.html" ><B CLASS="function" >get_included_files()</B ></A >, <A HREF="function.readfile.html" ><B CLASS="function" >readfile()</B ></A >, and <A HREF="function.virtual.html" ><B CLASS="function" >virtual()</B ></A >. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.require-once.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="functions.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.require-once.html" ><B CLASS="function" >require_once()</B ></A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="control-structures.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Functions</TD ></TR ></TABLE ></DIV ></BODY ></HTML >