uTools-Manuals/docs/php/include_once.html
2019-04-08 23:22:26 +08:00

46 lines
2.6 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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 class="docs"><div id="layout">
<div id="layout-content"><div id="function.include-once" class="sect1">
<h2 class="title"><span class="function"><strong>include_once</strong></span></h2>
<p class="verinfo">(PHP 4, PHP 5, PHP 7)</p>
<p class="para">
<em>include_once</em> 语句在脚本执行期间包含并运行指定文件。此行为和
<span class="function"><a href="include.html" class="function">include</a></span>
语句类似,唯一区别是如果该文件中已经被包含过,则不会再次包含。如同此语句名字暗示的那样,只会包含一次。
</p>
<p class="para">
<em>include_once</em>
可以用于在脚本执行期间同一个文件有可能被包含超过一次的情况下,想确保它只被包含一次以避免函数重定义,变量重新赋值等问题。
</p>
<p class="para">
更多信息参见 <span class="function"><a href="include.html" class="function">include</a></span> 文档。
</p>
<p class="para">
<blockquote class="note"><p><strong class="note">Note</strong>:
<p class="para">
在 PHP 4中<em>_once</em> 的行为在不区分大小写字母的操作系统(例如
Windows中有所不同例如
<div class="example" id="example-134">
<p><strong>Example #1 <span class="function"><strong>include_once</strong></span> 在 PHP 4 运行于不区分大小写的操作系统中</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><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;这将包含&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;这将再次包含&nbsp;a.php&nbsp;PHP&nbsp;4<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
</div>
</p>
<p class="para">
此行为在 PHP 5 中改了,例如在 Windows 中路径先被规格化,因此
<var class="filename">C:\PROGRA~1\A.php</var>
<var class="filename">C:\Program Files\a.php</var> 的实现一样,文件只会被包含一次。
</p>
</p></blockquote>
</p>
</div></div></div></body></html>