Sophie

Sophie

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

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>Gets information about a file using an open file pointer</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.fseek.html">fseek</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.ftell.html">ftell</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.fstat" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">fstat</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">fstat</span> &mdash; <span class="dc-title">Gets information about a file using an open file pointer</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.fstat-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><strong>fstat</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$handle</code></span>
   )</div>

  <p class="para rdfs-comment">
   Gathers the statistics of the file opened by the file
   pointer <em><code class="parameter">handle</code></em>. This function is similar to the
    <span class="function"><a href="function.stat.html" class="function">stat()</a></span> function except that it operates
   on an open file pointer instead of a filename.
  </p>
 </div>


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

    <dt>

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

      <p class="para">A file system pointer <span class="type"><a href="language.types.resource.html" class="type resource">resource</a></span>
that is typically created using  <span class="function"><a href="function.fopen.html" class="function">fopen()</a></span>.</p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.fstat-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns an array with the statistics of the file; the format of the array
   is described in detail on the  <span class="function"><a href="function.stat.html" class="function">stat()</a></span> manual page.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.fstat-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-2394">
    <p><strong>Example #1  <span class="function"><strong>fstat()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;open&nbsp;a&nbsp;file<br /></span><span style="color: #0000BB">$fp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">"/etc/passwd"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"r"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;gather&nbsp;statistics<br /></span><span style="color: #0000BB">$fstat&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fstat</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;close&nbsp;the&nbsp;file<br /></span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;print&nbsp;only&nbsp;the&nbsp;associative&nbsp;part<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">array_slice</span><span style="color: #007700">(</span><span style="color: #0000BB">$fstat</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">13</span><span style="color: #007700">));<br /><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>
Array
(
    [dev] =&gt; 771
    [ino] =&gt; 488704
    [mode] =&gt; 33188
    [nlink] =&gt; 1
    [uid] =&gt; 0
    [gid] =&gt; 0
    [rdev] =&gt; 0
    [size] =&gt; 1114
    [atime] =&gt; 1061067181
    [mtime] =&gt; 1056136526
    [ctime] =&gt; 1056136526
    [blksize] =&gt; 4096
    [blocks] =&gt; 8
)
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.fstat-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">This function will not work on
<a href="features.remote-files.html" class="link">remote files</a> as the file to
be examined must be accessible via the server&#039;s filesystem.</span></p></blockquote>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.fseek.html">fseek</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.ftell.html">ftell</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>