mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 05:26:57 +08:00
122 lines
5.8 KiB
HTML
122 lines
5.8 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>Determine accessibility of a file</title>
|
||
</head>
|
||
<body class="docs"><div id="layout">
|
||
<div id="layout-content"><div id="function.posix-access" class="refentry">
|
||
<div class="refnamediv">
|
||
<h1 class="refname">posix_access</h1>
|
||
<p class="verinfo">(PHP 5 >= 5.1.0, PHP 7)</p><p class="refpurpose"><span class="refname">posix_access</span> — <span class="dc-title">
|
||
Determine accessibility of a file
|
||
</span></p>
|
||
|
||
</div>
|
||
<div class="refsect1 description" id="refsect1-function.posix-access-description">
|
||
<h3 class="title">说明</h3>
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><strong>posix_access</strong></span>
|
||
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$file</code></span>
|
||
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code><span class="initializer"> = POSIX_F_OK</span></span>
|
||
] ) : <span class="type">bool</span></div>
|
||
|
||
<p class="para rdfs-comment">
|
||
<span class="function"><strong>posix_access()</strong></span> checks the user's permission of a file.
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 parameters" id="refsect1-function.posix-access-parameters">
|
||
<h3 class="title">参数</h3>
|
||
<p class="para">
|
||
<dl>
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">file</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
The name of the file to be tested.
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">mode</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
A mask consisting of one or more of <strong><code>POSIX_F_OK</code></strong>,
|
||
<strong><code>POSIX_R_OK</code></strong>, <strong><code>POSIX_W_OK</code></strong> and
|
||
<strong><code>POSIX_X_OK</code></strong>.
|
||
</p>
|
||
<p class="para">
|
||
<strong><code>POSIX_R_OK</code></strong>, <strong><code>POSIX_W_OK</code></strong> and
|
||
<strong><code>POSIX_X_OK</code></strong> request checking whether the file
|
||
exists and has read, write and execute permissions, respectively.
|
||
<strong><code>POSIX_F_OK</code></strong> just requests checking for the
|
||
existence of the file.
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
</dl>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 returnvalues" id="refsect1-function.posix-access-returnvalues">
|
||
<h3 class="title">返回值</h3>
|
||
<p class="para">
|
||
成功时返回 <strong><code>TRUE</code></strong>, 或者在失败时返回 <strong><code>FALSE</code></strong>。
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 examples" id="refsect1-function.posix-access-examples">
|
||
<h3 class="title">范例</h3>
|
||
<p class="para">
|
||
<div class="example" id="example-4331">
|
||
<p><strong>Example #1 <span class="function"><strong>posix_access()</strong></span> example</strong></p>
|
||
<div class="example-contents"><p>
|
||
This example will check if the $file is readable and writable, otherwise
|
||
will print an error message.
|
||
</p></div>
|
||
<div class="example-contents">
|
||
<div class="phpcode"><pre><span style="color: #000000">
|
||
<span style="color: #0000BB"><?php<br /><br />$file </span><span style="color: #007700">= </span><span style="color: #DD0000">'some_file'</span><span style="color: #007700">;<br /><br />if (</span><span style="color: #0000BB">posix_access</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">, </span><span style="color: #0000BB">POSIX_R_OK </span><span style="color: #007700">| </span><span style="color: #0000BB">POSIX_W_OK</span><span style="color: #007700">)) {<br /> echo </span><span style="color: #DD0000">'The file is readable and writable!'</span><span style="color: #007700">;<br /><br />} else {<br /> </span><span style="color: #0000BB">$error </span><span style="color: #007700">= </span><span style="color: #0000BB">posix_get_last_error</span><span style="color: #007700">();<br /><br /> echo </span><span style="color: #DD0000">"Error </span><span style="color: #0000BB">$error</span><span style="color: #DD0000">: " </span><span style="color: #007700">. </span><span style="color: #0000BB">posix_strerror</span><span style="color: #007700">(</span><span style="color: #0000BB">$error</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">?></span>
|
||
</span>
|
||
</pre></div>
|
||
</div>
|
||
|
||
</div>
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 notes" id="refsect1-function.posix-access-notes">
|
||
<h3 class="title">注释</h3>
|
||
<blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">当启用
|
||
<a href="features.safe_mode.html" class="link">安全模式</a>时,
|
||
PHP 会检查被操作的文件或目录是否与被执行的脚本有相同的 UID(所有者)。</span></p></blockquote>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 seealso" id="refsect1-function.posix-access-seealso">
|
||
<h3 class="title">参见</h3>
|
||
<p class="para">
|
||
<ul class="simplelist">
|
||
<li class="member"><span class="function"><a href="posix_get_last_error.html" class="function" rel="rdfs-seeAlso">posix_get_last_error()</a> - Retrieve the error number set by the last posix function that failed</span></li>
|
||
<li class="member"><span class="function"><a href="posix_strerror.html" class="function" rel="rdfs-seeAlso">posix_strerror()</a> - Retrieve the system error message associated with the given errno</span></li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
|
||
|
||
</div></div></div></body></html> |