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

📄 function.posix-access.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>Determine accessibility of a file</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="ref.posix.html">POSIX Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.posix-ctermid.html">posix_ctermid</a></div> <div class="up"><a href="ref.posix.html">POSIX Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.posix-access" class="refentry"> <div class="refnamediv">  <h1 class="refname">posix_access</h1>  <p class="verinfo">(PHP 5 &gt;= 5.1.0)</p><p class="refpurpose"><span class="refname">posix_access</span> &mdash; <span class="dc-title">   Determine accessibility of a file  </span></p> </div> <div class="refsect1 description">  <h3 class="title">Description</h3>  <div class="methodsynopsis dc-description">   <span class="type">bool</span> <span class="methodname"><b><b>posix_access</b></b></span>    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$file</tt></span>   [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$mode</tt></span>  ] )</div>  <p class="para rdfs-comment">   <b>posix_access()</b> checks the user&#039;s permission of a file.  </p> </div> <div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <dl>    <dt>     <span class="term"><i><tt class="parameter">file</tt></i></span>      <dd>       <p class="para">        The name of the file to be tested.       </p>      </dd>     </dt>    <dt>     <span class="term"><i><tt class="parameter">mode</tt></i></span>      <dd>       <p class="para">        A mask consisting of one or more of <b><tt>POSIX_F_OK</tt></b>,        <b><tt>POSIX_R_OK</tt></b>, <b><tt>POSIX_W_OK</tt></b> and        <b><tt>POSIX_X_OK</tt></b>. Defaults to        <b><tt>POSIX_F_OK</tt></b>.       </p>       <p class="para">        <b><tt>POSIX_R_OK</tt></b>, <b><tt>POSIX_W_OK</tt></b> and        <b><tt>POSIX_X_OK</tt></b> request checking whether the file        exists and has read, write and execute permissions, respectively.        <b><tt>POSIX_F_OK</tt></b> just requests checking for the        existence of the file.       </p>      </dd>     </dt>   </dl>  </p> </div> <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">   Returns <b><tt>TRUE</tt></b> on success or <b><tt>FALSE</tt></b> on failure.  </p> </div> <div class="refsect1 examples">  <h3 class="title">Examples</h3>  <p class="para">   <div class="example">    <p><b>Example #1 <b>posix_access()</b> example</b></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"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$file&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'some_file'</span><span style="color: #007700">;<br /><br />if&nbsp;(</span><span style="color: #0000BB">posix_access</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">POSIX_R_OK&nbsp;</span><span style="color: #007700">|&nbsp;</span><span style="color: #0000BB">POSIX_W_OK</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'The&nbsp;file&nbsp;is&nbsp;readable&nbsp;and&nbsp;writable!'</span><span style="color: #007700">;<br /><br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$error&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">posix_get_last_error</span><span style="color: #007700">();<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Error&nbsp;$error:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</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">?&gt;</span></span></code></div>    </div>   </div>  </p> </div> <div class="refsect1 notes">  <h3 class="title">Notes</h3>  <blockquote><p><b class="note">Note</b>: <span class="simpara">When <a href="features.safe-mode.html" class="link">safe mode</a> is enabled, PHP checks whether the files or directories being operated upon have the same UID (owner) as the script that is being executed.</span></p></blockquote> </div> <div class="refsect1 seealso">  <h3 class="title">See Also</h3>  <p class="para">   <ul class="simplelist">    <li class="member"><a href="function.posix-get-last-error.html" class="function" rel="rdfs-seeAlso">posix_get_last_error()</a></li>    <li class="member"><a href="function.posix-strerror.html" class="function" rel="rdfs-seeAlso">posix_strerror()</a></li>   </ul>  </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.posix.html">POSIX Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.posix-ctermid.html">posix_ctermid</a></div> <div class="up"><a href="ref.posix.html">POSIX Functions</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 + -