mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-29 04:52:50 +08:00
206 lines
7.9 KiB
HTML
206 lines
7.9 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>寻找与模式匹配的文件路径</title>
|
||
</head>
|
||
<body class="docs"><div id="layout">
|
||
<div id="layout-content"><div id="function.glob" class="refentry">
|
||
<div class="refnamediv">
|
||
<h1 class="refname">glob</h1>
|
||
<p class="verinfo">(PHP 4 >= 4.3.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">glob</span> — <span class="dc-title">寻找与模式匹配的文件路径</span></p>
|
||
|
||
</div>
|
||
<div class="refsect1 description" id="refsect1-function.glob-description">
|
||
<h3 class="title">说明</h3>
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><strong>glob</strong></span>
|
||
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$pattern</code></span>
|
||
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = 0</span></span>
|
||
] ) : <span class="type">array</span></div>
|
||
|
||
<p class="para rdfs-comment">
|
||
<span class="function"><strong>glob()</strong></span> 函数依照 libc glob() 函数使用的规则寻找所有与
|
||
<code class="parameter">pattern</code> 匹配的文件路径,类似于一般 shells
|
||
所用的规则一样。不进行缩写扩展或参数替代。
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 parameters" id="refsect1-function.glob-parameters">
|
||
<h3 class="title">参数</h3>
|
||
<p class="para">
|
||
<dl>
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">pattern</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
The pattern. No tilde expansion or parameter substitution is done.
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">flags</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
有效标记有:
|
||
<ul class="itemizedlist">
|
||
<li class="listitem">
|
||
<span class="simpara">
|
||
<strong><code>GLOB_MARK</code></strong> - 在每个返回的项目中加一个斜线
|
||
</span>
|
||
</li>
|
||
<li class="listitem">
|
||
<span class="simpara">
|
||
<strong><code>GLOB_NOSORT</code></strong> - 按照文件在目录中出现的原始顺序返回(不排序)
|
||
</span>
|
||
</li>
|
||
<li class="listitem">
|
||
<span class="simpara">
|
||
<strong><code>GLOB_NOCHECK</code></strong> - 如果没有文件匹配则返回用于搜索的模式
|
||
</span>
|
||
</li>
|
||
<li class="listitem">
|
||
<span class="simpara">
|
||
<strong><code>GLOB_NOESCAPE</code></strong> - 反斜线不转义元字符
|
||
</span>
|
||
</li>
|
||
<li class="listitem">
|
||
<span class="simpara">
|
||
<strong><code>GLOB_BRACE</code></strong> - 扩充 {a,b,c} 来匹配 'a','b' 或 'c'
|
||
</span>
|
||
</li>
|
||
<li class="listitem">
|
||
<span class="simpara">
|
||
<strong><code>GLOB_ONLYDIR</code></strong> - 仅返回与模式匹配的目录项
|
||
</span>
|
||
</li>
|
||
<li class="listitem">
|
||
<span class="simpara">
|
||
<strong><code>GLOB_ERR</code></strong> - 停止并读取错误信息(比如说不可读的目录),默认的情况下忽略所有错误
|
||
</span>
|
||
</li>
|
||
</ul>
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
</dl>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 returnvalues" id="refsect1-function.glob-returnvalues">
|
||
<h3 class="title">返回值</h3>
|
||
<p class="para">返回一个包含有匹配文件/目录的数组。如果出错返回 <strong><code>FALSE</code></strong>。
|
||
</p>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>:
|
||
<p class="para">
|
||
On some systems it is impossible to distinguish between empty match and an
|
||
error.
|
||
</p>
|
||
</p></blockquote>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 changelog" id="refsect1-function.glob-changelog">
|
||
<h3 class="title">更新日志</h3>
|
||
<p class="para">
|
||
<table class="doctable informaltable">
|
||
|
||
<thead>
|
||
<tr>
|
||
<th>版本</th>
|
||
<th>说明</th>
|
||
</tr>
|
||
|
||
</thead>
|
||
|
||
<tbody class="tbody">
|
||
<tr>
|
||
<td>5.1.0</td>
|
||
<td>
|
||
<strong><code>GLOB_ERR</code></strong> was added
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>4.3.3</td>
|
||
<td>
|
||
<strong><code>GLOB_ONLYDIR</code></strong>
|
||
在 Windows 或者其它不使用 GNU C 库的系统上开始可用。
|
||
</td>
|
||
</tr>
|
||
|
||
</tbody>
|
||
|
||
</table>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 examples" id="refsect1-function.glob-examples">
|
||
<h3 class="title">范例</h3>
|
||
<p class="para">
|
||
<div class="example" id="example-2811">
|
||
<p><strong>Example #1 怎样用 <span class="function"><strong>glob()</strong></span> 方便地替代
|
||
<span class="function"><a href="opendir.html" class="function">opendir()</a></span> 和相关函数</strong></p>
|
||
<div class="example-contents">
|
||
<div class="phpcode"><pre><span style="color: #000000">
|
||
<span style="color: #0000BB"><?php<br /></span><span style="color: #007700">foreach (</span><span style="color: #0000BB">glob</span><span style="color: #007700">(</span><span style="color: #DD0000">"*.txt"</span><span style="color: #007700">) as </span><span style="color: #0000BB">$filename</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">"</span><span style="color: #0000BB">$filename</span><span style="color: #DD0000"> size " </span><span style="color: #007700">. </span><span style="color: #0000BB">filesize</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?></span>
|
||
</span>
|
||
</pre></div>
|
||
</div>
|
||
|
||
<div class="example-contents"><p>以上例程的输出类似于:</p></div>
|
||
<div class="example-contents screen">
|
||
<div class="cdata"><pre>
|
||
funclist.txt size 44686
|
||
funcsummary.txt size 267625
|
||
quickref.txt size 137820
|
||
</pre></div>
|
||
</div>
|
||
</div>
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 notes" id="refsect1-function.glob-notes">
|
||
<h3 class="title">注释</h3>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">此函数不能作用于<a href="features.remote_files.html" class="link">远程文件</a>,被检查的文件必须是可通过服务器的文件系统访问的。</span></p></blockquote>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>:
|
||
<span class="simpara">
|
||
此函数在一些系统上还不能工作(例如一些旧的 Sun OS)。
|
||
</span>
|
||
</p></blockquote>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>:
|
||
<span class="simpara">
|
||
<strong><code>GLOB_BRACE</code></strong> 在一些非 GNU 系统上无效,比如 Solaris。
|
||
</span>
|
||
</p></blockquote>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 seealso" id="refsect1-function.glob-seealso">
|
||
<h3 class="title">参见</h3>
|
||
<p class="para">
|
||
<ul class="simplelist">
|
||
<li class="member"><span class="function"><a href="opendir.html" class="function" rel="rdfs-seeAlso">opendir()</a> - 打开目录句柄</span></li>
|
||
<li class="member"><span class="function"><a href="readdir.html" class="function" rel="rdfs-seeAlso">readdir()</a> - 从目录句柄中读取条目</span></li>
|
||
<li class="member"><span class="function"><a href="closedir.html" class="function" rel="rdfs-seeAlso">closedir()</a> - 关闭目录句柄</span></li>
|
||
<li class="member"><span class="function"><a href="fnmatch.html" class="function" rel="rdfs-seeAlso">fnmatch()</a> - 用模式匹配文件名</span></li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
|
||
</div></div></div></body></html> |