<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.filesystem.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.stat.php',
    1 => 'stat',
    2 => 'Renvoie les informations &agrave; propos d\'un fichier',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => 'Fonctions sur les syst&egrave;mes de fichiers',
  ),
  'prev' => 
  array (
    0 => 'function.set-file-buffer.php',
    1 => 'set_file_buffer',
  ),
  'next' => 
  array (
    0 => 'function.symlink.php',
    1 => 'symlink',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/filesystem/functions/stat.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.stat" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">stat</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">stat</span> &mdash; <span class="dc-title">Renvoie les informations à propos d&#039;un fichier</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.stat-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>stat</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$filename</code></span>): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   Renvoie les informations à propos du fichier <code class="parameter">filename</code>.
   Si <code class="parameter">filename</code> est un lien symbolique, les informations
   proviennent du fichier lui-même, et non du lien symbolique.
   Avant PHP 7.4.0, sous Windows <abbr class="abbrev">NTS</abbr> compile les
   valeurs statiques <code class="literal">size</code>, <code class="literal">atime</code>,
   <code class="literal">mtime</code> et <code class="literal">ctime</code> depuis les liens
   symboliques, dans ce cas.
  </p>
  <p class="para">
   <span class="function"><a href="function.lstat.php" class="function">lstat()</a></span> est identique à
   <span class="function"><strong>stat()</strong></span> sauf que les informations seront alors basées
   sur le lien symbolique.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.stat-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">filename</code></dt>
     <dd>
      <p class="para">
       Le chemin vers le fichier.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.stat-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   <table class="doctable table">
    <caption><strong>Format du résultat de <span class="function"><strong>stat()</strong></span> et
     <span class="function"><a href="function.fstat.php" class="function">fstat()</a></span></strong></caption>
    
     <thead>
      <tr>
       <th>Numéro</th>
       <th>Nom</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>0</td>
       <td>dev</td>
       <td>volume (***)</td>
      </tr>

      <tr>
       <td>1</td>
       <td>ino</td>
       <td>Numéro d&#039;inode (****)</td>
      </tr>

      <tr>
       <td>2</td>
       <td>mode</td>
       <td>droit d&#039;accès à l&#039;inode *****</td>
      </tr>

      <tr>
       <td>3</td>
       <td>nlink</td>
       <td>nombre de liens</td>
      </tr>

      <tr>
       <td>4</td>
       <td>uid</td>
       <td>userid du propriétaire (*)</td>
      </tr>

      <tr>
       <td>5</td>
       <td>gid</td>
       <td>groupid du propriétaire (*)</td>
      </tr>

      <tr>
       <td>6</td>
       <td>rdev</td>
       <td>type du volume, si le volume est une inode</td>
      </tr>

      <tr>
       <td>7</td>
       <td>size</td>
       <td>taille en octets</td>
      </tr>

      <tr>
       <td>8</td>
       <td>atime</td>
       <td>date de dernier accès (Unix timestamp)</td>
      </tr>

      <tr>
       <td>9</td>
       <td>mtime</td>
       <td>date de dernière modification (Unix timestamp)</td>
      </tr>

      <tr>
       <td>10</td>
       <td>ctime</td>
       <td>date de dernier changement d&#039;inode (Unix timestamp)</td>
      </tr>

      <tr>
       <td>11</td>
       <td>blksize</td>
       <td>taille de bloc (**)</td>
      </tr>

      <tr>
       <td>12</td>
       <td>blocks</td>
       <td>nombre de blocs de 512 octets alloués (**)</td>
      </tr>

     </tbody>
    
   </table>

  </p>
  <p class="para">
   * - Sous Windows, ceci sera toujours <code class="literal">0</code>.
  </p>
  <p class="para">
   ** - uniquement sur les systèmes qui supportent le type <code class="literal">st_blksize</code>.
   Les autres systèmes (p. ex. Windows) retournent <code class="literal">-1</code>.
  </p>
  <p class="para">
   *** - Sous Windows, à partir de PHP 7.4.0, ce sera le numéro de série du volume qui
   contient le fichier, qui sera un entier 64-bit <em>non signé</em>
   qui peut déborder. Auparavant, c&#039;était la représentation numérique de la lettre
   du volume (c.-à-d. <code class="literal">2</code> pour <code class="literal">C:</code>) pour la fonction
   <span class="function"><strong>stat()</strong></span>, et <code class="literal">0</code> pour la fonction
   <span class="function"><a href="function.lstat.php" class="function">lstat()</a></span>.
  </p>
  <p class="para">
   **** - Sous Windows, à partir de PHP 7.4.0, c&#039;est l&#039;identifiant associé avec le fichier,
   qui sera un entier 64-bit <em>non signé</em> qui peut déborder.
   Auparavant, c&#039;était toujours <code class="literal">0</code>.
  </p>
  <p class="para">
   ***** Sous Windows, le bit de la permission d&#039;écriture est défini en
   fonction de l&#039;attribut lecture seule du fichier, et la même valeur est
   rapportée pour tous les utilisateurs, groupe, et propriétaire.
   L&#039;ACL n&#039;est pas prise en compte, contrairement à <span class="function"><a href="function.is-writable.php" class="function">is_writable()</a></span>.
  </p>
  <p class="para">
   La valeur de <code class="literal">mode</code> contient des informations lues par
   plusieurs fonctions. Écrite en octal, en commençant par la droite,
   les trois premiers chiffres sont retournés par <span class="function"><a href="function.chmod.php" class="function">chmod()</a></span>.
   Le chiffre suivant est ignoré par PHP. Les deux chiffres suivants indiquent
   le type de fichier :
   <table class="doctable table">
    <caption><strong>Les types de fichiers <code class="literal">mode</code></strong></caption>
    
     <thead>
      <tr>
       <th><code class="literal">mode</code> en octal</th>
       <th>Signification</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td><code class="literal">0140000</code></td>
       <td>socket</td>
      </tr>

      <tr>
       <td><code class="literal">0120000</code></td>
       <td>lien symbolique</td>
      </tr>

      <tr>
       <td><code class="literal">0100000</code></td>
       <td>fichier régulier</td>
      </tr>

      <tr>
       <td><code class="literal">0060000</code></td>
       <td>périphérique bloc</td>
      </tr>

      <tr>
       <td><code class="literal">0040000</code></td>
       <td>dossier</td>
      </tr>

      <tr>
       <td><code class="literal">0020000</code></td>
       <td>périphérique de caractère</td>
      </tr>

      <tr>
       <td><code class="literal">0010000</code></td>
       <td>FIFO (un tube nommé)</td>
      </tr>

     </tbody>
    
   </table>

   Ainsi, par exemple, un fichier régulier pourrait être
   <code class="literal">0100644</code> et un dossier pourrait être
   <code class="literal">0040755</code>.
  </p>
  <p class="para">
   En cas d&#039;erreur, <span class="function"><strong>stat()</strong></span> retourne <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">
    Comme le type entier de PHP est signé et que de nombreuses plates-formes
    utilisent des entiers de 32 bits, certaines fonctions relatives au système
    de fichiers peuvent retourner des résultats étranges pour les fichiers de
    taille supérieure à 2 Go.
</span></p></blockquote>
 </div>


 <div class="refsect1 errors" id="refsect1-function.stat-errors">
  <h3 class="title">Erreurs / Exceptions</h3>
  <p class="para">
   Si une erreur survient, une alerte de type
   <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> est émise.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.stat-changelog">
  <h3 class="title">Historique</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>7.4.0</td>
      <td>
       Sous Windows, le numéro du volume est maintenant le numéro de série qui contient
       le fichier, et le numéro de l&#039;inode est l&#039;identifiant associé avec le fichier.
      </td>
     </tr>

     <tr>
      <td>7.4.0</td>
      <td>
       Les valeurs statiques <code class="literal">size</code>, <code class="literal">atime</code>,
       <code class="literal">mtime</code> et <code class="literal">ctime</code> des liens symboliques
       sont toujours ceux de la cible. Ce n&#039;était précédemment pas le cas
       pour les builds <abbr class="abbrev">NTS</abbr> sous Windows.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.stat-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Exemple avec <span class="function"><strong>stat()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/* Récupération des informations */<br /></span><span style="color: #0000BB">$stat </span><span style="color: #007700">= </span><span style="color: #0000BB">stat</span><span style="color: #007700">(</span><span style="color: #DD0000">'C:\php\php.exe'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*<br /> * Affichage de la date et heure de l'accès à ce fichier,<br /> * identique à l'appel à la fonction fileatime()<br /> */<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">'Date et heure d\'accès : ' </span><span style="color: #007700">. </span><span style="color: #0000BB">$stat</span><span style="color: #007700">[</span><span style="color: #DD0000">'atime'</span><span style="color: #007700">];<br /><br /></span><span style="color: #FF8000">/*<br /> * Affiche de la date et heure de modification du fichier,<br /> * identique à l'appel à la fonction filemtime()<br /> */<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">'Date et heure de modification : ' </span><span style="color: #007700">. </span><span style="color: #0000BB">$stat</span><span style="color: #007700">[</span><span style="color: #DD0000">'mtime'</span><span style="color: #007700">];<br /><br /></span><span style="color: #FF8000">/* Affichage du numéro du device */<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">'Numéro du Device : ' </span><span style="color: #007700">. </span><span style="color: #0000BB">$stat</span><span style="color: #007700">[</span><span style="color: #DD0000">'dev'</span><span style="color: #007700">];<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example-2">
    <p><strong>Exemple #2 Utilisation des informations issues de <span class="function"><strong>stat()</strong></span>
    conjointement avec la fonction <span class="function"><a href="function.touch.php" class="function">touch()</a></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/* Récupération des informations issues de la fonction stat */<br /></span><span style="color: #0000BB">$stat </span><span style="color: #007700">= </span><span style="color: #0000BB">stat</span><span style="color: #007700">(</span><span style="color: #DD0000">'C:\php\php.exe'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* L'accès aux informations a-t-il échoué ? */<br /></span><span style="color: #007700">if (!</span><span style="color: #0000BB">$stat</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">'L\'appel à stat() a échoué...'</span><span style="color: #007700">;<br />} else {<br />    </span><span style="color: #FF8000">/*<br />     * Nous voulons que la date et heure d'accès soit d'une<br />     * semaine après la date courante.<br />     */<br />    </span><span style="color: #0000BB">$atime </span><span style="color: #007700">= </span><span style="color: #0000BB">$stat</span><span style="color: #007700">[</span><span style="color: #DD0000">'atime'</span><span style="color: #007700">] + </span><span style="color: #0000BB">604800</span><span style="color: #007700">;<br /><br />    </span><span style="color: #FF8000">/* Touchons le fichier ! */<br />    </span><span style="color: #007700">if(!</span><span style="color: #0000BB">touch</span><span style="color: #007700">(</span><span style="color: #DD0000">'some_file.txt'</span><span style="color: #007700">, </span><span style="color: #0000BB">time</span><span style="color: #007700">(), </span><span style="color: #0000BB">$atime</span><span style="color: #007700">)) {<br />        echo </span><span style="color: #DD0000">'Échec lors de l\'appel à la fonction touch()...'</span><span style="color: #007700">;<br />    } else {<br />        echo </span><span style="color: #DD0000">'L\'appel à touch() a réussi...'</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" id="refsect1-function.stat-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para">
 Notez que la précision temporelle peut varier selon le système de fichiers utilisé.
</p></p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">
 Les résultats de cette fonction sont mis en cache.
 Voyez la fonction <span class="function"><a href="function.clearstatcache.php" class="function">clearstatcache()</a></span> pour plus de détails.
</span></p></blockquote>
  <div class="tip"><strong class="tip">Astuce</strong><p class="simpara">
 À partir de PHP 5.0.0, cette fonction peut aussi être utilisée avec <em>quelques</em> protocoles url.
 Lisez <a href="wrappers.php" class="xref">Liste des protocoles et des gestionnaires support&eacute;s</a> pour connaître les protocoles supportant la famille de fonctionnalités de
 <span class="function"><strong>stat()</strong></span>.
</p></div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.stat-seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.lstat.php" class="function" rel="rdfs-seeAlso">lstat()</a> - Retourne les informations sur un fichier ou un lien symbolique</span></li>
    <li><span class="function"><a href="function.fstat.php" class="function" rel="rdfs-seeAlso">fstat()</a> - Lit les informations sur un fichier &agrave; partir d'un pointeur de fichier</span></li>
    <li><span class="function"><a href="function.filemtime.php" class="function" rel="rdfs-seeAlso">filemtime()</a> - Lit la date de derni&egrave;re modification du fichier</span></li>
    <li><span class="function"><a href="function.filegroup.php" class="function" rel="rdfs-seeAlso">filegroup()</a> - Lire le nom du groupe</span></li>
    <li><span class="classname"><a href="class.splfileinfo.php" class="classname">SplFileInfo</a></span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>