<?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.touch.php',
    1 => 'touch',
    2 => 'Modifie la date de modification et de dernier acc&egrave;s d\'un fichier',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => 'Fonctions sur les syst&egrave;mes de fichiers',
  ),
  'prev' => 
  array (
    0 => 'function.tmpfile.php',
    1 => 'tmpfile',
  ),
  'next' => 
  array (
    0 => 'function.umask.php',
    1 => 'umask',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/filesystem/functions/touch.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.touch" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">touch</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">touch</span> &mdash; <span class="dc-title">Modifie la date de modification et de dernier accès d&#039;un fichier</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.touch-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>touch</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="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$mtime</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$atime</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Tente de forcer la date de modification du fichier
   désigné par le paramètre <code class="parameter">filename</code> à la date
   spécifiée par le paramètre <code class="parameter">mtime</code>.
   Il est à noter que la date de dernier accès est modifiée, quel que
   soit le nombre de paramètres.
  </p>
  <p class="para">
   Si le fichier n&#039;existe pas, PHP tentera de le créer.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.touch-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 nom du fichier à créer.
      </p>
     </dd>
    
    
     <dt><code class="parameter">mtime</code></dt>
     <dd>
      <p class="para">
       La date de création. Si <code class="parameter">mtime</code> est omis,
       c&#039;est l&#039;heure courante <span class="function"><a href="function.time.php" class="function">time()</a></span> qui est utilisée.
      </p>
     </dd>
    
    
     <dt><code class="parameter">atime</code></dt>
     <dd>
      <p class="para">
       Si non <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>, l&#039;heure d&#039;accès au fichier fourni sera défini à la valeur
       du paramètre <code class="parameter">atime</code>. Sinon, elle sera définie à
       la valeur passée au paramètre <code class="parameter">mtime</code>.
       Si tous les deux sont <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>, l&#039;heure courante du système sera utilisée.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.touch-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Cette fonction retourne <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> en cas de succès ou <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> si une erreur survient.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.touch-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>8.0.0</td>
      <td>
       <code class="parameter">mtime</code> et <code class="parameter">atime</code>
       sont désormais nullable.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.touch-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>touch()</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: #007700">if (</span><span style="color: #0000BB">touch</span><span style="color: #007700">(</span><span style="color: #0000BB">$FileName</span><span style="color: #007700">)) {<br />    echo </span><span style="color: #DD0000">"La date de modification de </span><span style="color: #0000BB">$FileName</span><span style="color: #DD0000"> a été modifiée à la date courante"</span><span style="color: #007700">;<br />} else {<br />    echo </span><span style="color: #DD0000">"Désolé, il est impossible de changer la date de modification de </span><span style="color: #0000BB">$FileName</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />}<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 Exemple avec <span class="function"><strong>touch()</strong></span> en utilisant le paramètre
    <code class="parameter">mtime</code></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">/*<br /> * Ceci est la date et l'heure du dernier accès, nous y ajoutons 1 heure<br /> * dans le passé.<br /> */<br /></span><span style="color: #0000BB">$time </span><span style="color: #007700">= </span><span style="color: #0000BB">time</span><span style="color: #007700">() - </span><span style="color: #0000BB">3600</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">)) {<br />    echo </span><span style="color: #DD0000">'Whoops, une erreur est survenue...'</span><span style="color: #007700">;<br />} else {<br />    echo </span><span style="color: #DD0000">'L\'appel à la fonction touch() a réussi'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.touch-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>
 </div>


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