Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 2288

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!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>Clears file status cache</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.chown.html">chown</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.copy.html">copy</a></div>
 <div class="up"><a href="ref.filesystem.html">Filesystem Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.clearstatcache" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">clearstatcache</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">clearstatcache</span> &mdash; <span class="dc-title">Clears file status cache</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.clearstatcache-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><span class="type void">void</span></span> <span class="methodname"><strong>clearstatcache</strong></span>
    ([ <span class="methodparam"><span class="type">bool</span> <code class="parameter">$clear_realpath_cache</code><span class="initializer"> = false</span></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>
  ]] )</div>

  <p class="para rdfs-comment">
   When you use  <span class="function"><a href="function.stat.html" class="function">stat()</a></span>,  <span class="function"><a href="function.lstat.html" class="function">lstat()</a></span>, or
   any of the other functions listed in the affected functions list (below),
   PHP caches the information those functions return in order to provide
   faster performance. However, in certain cases, you may want to clear the
   cached information. For instance, if the same file is being checked
   multiple times within a single script, and that file is in danger of
   being removed or changed during that script&#039;s operation, you may elect to
   clear the status cache.  In these cases, you can use the
    <span class="function"><strong>clearstatcache()</strong></span> function to clear the information
   that PHP caches about a file.
  </p>
  <p class="para">
   You should also note that PHP doesn&#039;t cache information about non-existent
   files. So, if you call  <span class="function"><a href="function.file-exists.html" class="function">file_exists()</a></span> on a file that
   doesn&#039;t exist, it will return <strong><code>FALSE</code></strong> until you create the file. If you
   create the file, it will return <strong><code>TRUE</code></strong> even if you then delete the file.
   However  <span class="function"><a href="function.unlink.html" class="function">unlink()</a></span> clears the cache automatically.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    This function caches information about specific filenames, so you only
    need to call  <span class="function"><strong>clearstatcache()</strong></span> if you are performing
    multiple operations on the same filename and require the information
    about that particular file to not be cached.
   </p>
  </p></blockquote>
  <p class="para">
   Affected functions include  <span class="function"><a href="function.stat.html" class="function">stat()</a></span>,
    <span class="function"><a href="function.lstat.html" class="function">lstat()</a></span>,
    <span class="function"><a href="function.file-exists.html" class="function">file_exists()</a></span>,
    <span class="function"><a href="function.is-writable.html" class="function">is_writable()</a></span>,
    <span class="function"><a href="function.is-readable.html" class="function">is_readable()</a></span>,
    <span class="function"><a href="function.is-executable.html" class="function">is_executable()</a></span>,
    <span class="function"><a href="function.is-file.html" class="function">is_file()</a></span>,
    <span class="function"><a href="function.is-dir.html" class="function">is_dir()</a></span>,
    <span class="function"><a href="function.is-link.html" class="function">is_link()</a></span>,
    <span class="function"><a href="function.filectime.html" class="function">filectime()</a></span>,
    <span class="function"><a href="function.fileatime.html" class="function">fileatime()</a></span>,
    <span class="function"><a href="function.filemtime.html" class="function">filemtime()</a></span>,
    <span class="function"><a href="function.fileinode.html" class="function">fileinode()</a></span>,
    <span class="function"><a href="function.filegroup.html" class="function">filegroup()</a></span>,
    <span class="function"><a href="function.fileowner.html" class="function">fileowner()</a></span>,
    <span class="function"><a href="function.filesize.html" class="function">filesize()</a></span>,
    <span class="function"><a href="function.filetype.html" class="function">filetype()</a></span>, and
    <span class="function"><a href="function.fileperms.html" class="function">fileperms()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.clearstatcache-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">clear_realpath_cache</code></em></span>
     <dd>

      <p class="para">
       Whether to clear the realpath cache or not.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">filename</code></em></span>
     <dd>

      <p class="para">
       Clear the realpath and the stat cache for a specific filename only; only
       used if <em><code class="parameter">clear_realpath_cache</code></em> is <strong><code>TRUE</code></strong>.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.clearstatcache-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   No value is returned.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.clearstatcache-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.3.0</td>
       <td>
        Added optional <em><code class="parameter">clear_realpath_cache</code></em>
        and <em><code class="parameter">filename</code></em> parameters.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.clearstatcache-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-2351">
    <p><strong>Example #1  <span class="function"><strong>clearstatcache()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$file&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'output_log.txt'</span><span style="color: #007700">;<br /><br />function&nbsp;</span><span style="color: #0000BB">get_owner</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$stat&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">stat</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$user&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">posix_getpwuid</span><span style="color: #007700">(</span><span style="color: #0000BB">$stat</span><span style="color: #007700">[</span><span style="color: #DD0000">'uid'</span><span style="color: #007700">]);<br />&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">$user</span><span style="color: #007700">[</span><span style="color: #DD0000">'name'</span><span style="color: #007700">];<br />}<br /><br /></span><span style="color: #0000BB">$format&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"UID&nbsp;@&nbsp;%s:&nbsp;%s\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #0000BB">$format</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'r'</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">get_owner</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">chown</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'ross'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #0000BB">$format</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'r'</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">get_owner</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">clearstatcache</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #0000BB">$format</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'r'</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">get_owner</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output
something similar to:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
UID @ Sun, 12 Oct 2008 20:48:28 +0100: root
UID @ Sun, 12 Oct 2008 20:48:28 +0100: root
UID @ Sun, 12 Oct 2008 20:48:28 +0100: ross
</pre></div>
    </div>
   </div>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.chown.html">chown</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.copy.html">copy</a></div>
 <div class="up"><a href="ref.filesystem.html">Filesystem Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>