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

96 lines
5.2 KiB
HTML

<!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 和 require 文件名的 array</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.get-included-files" class="refentry">
<div class="refnamediv">
<h1 class="refname">get_included_files</h1>
<p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">get_included_files</span> &mdash; <span class="dc-title">返回被 include 和 require 文件名的 array</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.get-included-files-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>get_included_files</strong></span>
( <span class="methodparam">void</span>
) : <span class="type">array</span></div>
<p class="para rdfs-comment">
返回所有被
<span class="function"><a href="include.html" class="function">include</a></span><span class="function"><a href="include_once.html" class="function">include_once</a></span>
<span class="function"><a href="require.html" class="function">require</a></span><span class="function"><a href="require_once.html" class="function">require_once</a></span>
的文件名。
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.get-included-files-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
返回所有文件名称的 array。
</p>
<p class="para">
脚本最初被称为”被包含的文件“,所以脚本自身也会和 <span class="function"><a href="include.html" class="function">include</a></span> 系列函数引用的脚本列在一起。
</p>
<p class="para">
被多次 include 和 require 的文件在返回的 array 里只会列出一次。
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.get-included-files-examples">
<h3 class="title">范例</h3>
<p class="para">
<div class="example" id="example-499">
<p><strong>Example #1 <span class="function"><strong>get_included_files()</strong></span> 范例</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: #FF8000">//&nbsp;本文件是&nbsp;abc.php<br /><br /></span><span style="color: #007700">include&nbsp;</span><span style="color: #DD0000">'test1.php'</span><span style="color: #007700">;<br />include_once&nbsp;</span><span style="color: #DD0000">'test2.php'</span><span style="color: #007700">;<br />require&nbsp;</span><span style="color: #DD0000">'test3.php'</span><span style="color: #007700">;<br />require_once&nbsp;</span><span style="color: #DD0000">'test4.php'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$included_files&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">get_included_files</span><span style="color: #007700">();<br /><br />foreach&nbsp;(</span><span style="color: #0000BB">$included_files&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$filename</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$filename</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
<div class="example-contents"><p>以上例程会输出:</p></div>
<div class="example-contents screen">
<div class="cdata"><pre>
/path/to/abc.php
/path/to/test1.php
/path/to/test2.php
/path/to/test3.php
/path/to/test4.php
</pre></div>
</div>
</div>
</p>
</div>
<div class="refsect1 notes" id="refsect1-function.get-included-files-notes">
<h3 class="title">注释</h3>
<blockquote class="note"><p><strong class="note">Note</strong>:
<p class="para">
使用 <em>auto_prepend_file</em> 配置指令所包含的文件不会包含在返回的数组里。
</p>
</p></blockquote>
</div>
<div class="refsect1 seealso" id="refsect1-function.get-included-files-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="include.html" class="function" rel="rdfs-seeAlso">include</a> - include</span></li>
<li class="member"><span class="function"><a href="include_once.html" class="function" rel="rdfs-seeAlso">include_once</a> - include_once</span></li>
<li class="member"><span class="function"><a href="require.html" class="function" rel="rdfs-seeAlso">require</a> - require</span></li>
<li class="member"><span class="function"><a href="require_once.html" class="function" rel="rdfs-seeAlso">require_once</a> - require_once</span></li>
<li class="member"><span class="function"><a href="get_required_files.html" class="function" rel="rdfs-seeAlso">get_required_files()</a> - 别名 get_included_files</span></li>
</ul>
</p>
</div>
</div></div></div></body></html>