⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 function.require-once.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>require_once</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.include.html">include</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.include-once.html">include_once</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.require-once" class="sect1">   <h2 class="title"><b>require_once()</b></h2>   <p class="para">    The <b>require_once()</b> statement includes and evaluates    the specified file during the execution of the script.    This is a behavior similar to the <b>require()</b> statement,    with the only difference being that if the code from a file has already    been included, it will not be included again.  See the documentation for    <b>require()</b> for more information on how this statement    works.   </p>   <p class="para">    <b>require_once()</b> 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 class="para">     For examples on using <b>require_once()</b> and     <b>include_once()</b>, look at the     <a href="http://pear.php.net/" class="link external">&raquo; PEAR</a> code included in the     latest PHP source code distributions.   </p>   <p class="para">    Return values are the same as with <b>include()</b>. If the file    was already included, this function returns <b><tt>TRUE</tt></b>   </p>   <p class="para">    <blockquote><p><b class="note">Note</b>:            <b>require_once()</b> was added in PHP 4.0.1     <br />    </p></blockquote>   </p>   <p class="para">    <blockquote><p><b class="note">Note</b>:            Be aware, that the behaviour of <b>require_once()</b>      and <b>include_once()</b> may not be what you expect      on a non case sensitive operating system (such as Windows).      <div class="example">       <p><b>Example #1 <b>require_once()</b> is case insensitive on Windows</b></p>       <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">require_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">require_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;on&nbsp;Windows!&nbsp;(PHP&nbsp;4&nbsp;only)<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>        </div>      </div>      This behaviour changed in PHP 5 - 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 required just once.     <br />    </p></blockquote>   </p>   <div class="warning"><b class="warning">Warning</b><p class="para">Windows versions of PHPprior to PHP 4.3.0 do not support access of remote files via this function,even if <a href="filesystem.configuration.html#ini.allow-url-fopen" class="link">allow_url_fopen</a> is enabled.</p></div>   <p class="para">    See also <b>require()</b>,    <b>include()</b>, <b>include_once()</b>,    <a href="function.get-required-files.html" class="function">get_required_files()</a>,    <a href="function.get-included-files.html" class="function">get_included_files()</a>, <a href="function.readfile.html" class="function">readfile()</a>, and    <a href="function.virtual.html" class="function">virtual()</a>.   </p>  </div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.include.html">include</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.include-once.html">include_once</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>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -