<?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 => 'es',
  ),
  'this' => 
  array (
    0 => 'function.touch.php',
    1 => 'touch',
    2 => 'Modifica la fecha de modificaci&oacute;n y de &uacute;ltimo acceso de un fichero',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => 'Funciones del Sistema de Archivos',
  ),
  'prev' => 
  array (
    0 => 'function.tmpfile.php',
    1 => 'tmpfile',
  ),
  'next' => 
  array (
    0 => 'function.umask.php',
    1 => 'umask',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'es',
    '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">Modifica la fecha de modificación y de último acceso de un fichero</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.touch-description">
  <h3 class="title">Descripción</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">
   Intenta forzar la fecha de modificación del fichero
   designado por el parámetro <code class="parameter">filename</code> a la fecha
   especificada por el parámetro <code class="parameter">mtime</code>.
   Tenga en cuenta que la fecha de último acceso se modifica, independientemente
   del número de argumentos.
  </p>
  <p class="para">
   Si el fichero no existe, PHP intentará crearlo.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.touch-parameters">
  <h3 class="title">Parámetros</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">filename</code></dt>
     <dd>
      <p class="para">
       El nombre del fichero a crear.
      </p>
     </dd>
    
    
     <dt><code class="parameter">mtime</code></dt>
     <dd>
      <p class="para">
       La fecha de creación. Si <code class="parameter">mtime</code> es omitido,
       se utiliza la hora actual <span class="function"><a href="function.time.php" class="function">time()</a></span>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">atime</code></dt>
     <dd>
      <p class="para">
       Si no es <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>, la hora de acceso al fichero proporcionado se establecerá a la
       valor del parámetro <code class="parameter">atime</code>. De lo contrario, se establecerá a
       la valor pasada al parámetro <code class="parameter">mtime</code>.
       Si ambos son <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>, se utilizará la hora actual del sistema.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.touch-returnvalues">
  <h3 class="title">Valores devueltos</h3>
  <p class="para">
   Esta función retorna <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> en caso de éxito o <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> si ocurre un error.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.touch-changelog">
  <h3 class="title">Historial de cambios</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Versión</th>
      <th>Descripción</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">mtime</code> y <code class="parameter">atime</code>
       ahora son nullable.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.touch-examples">
  <h3 class="title">Ejemplos</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Ejemplo #1 Ejemplo con <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 fecha de modificación de </span><span style="color: #0000BB">$FileName</span><span style="color: #DD0000"> ha sido modificada a la fecha actual"</span><span style="color: #007700">;<br />} else {<br />    echo </span><span style="color: #DD0000">"Lo sentimos, no es posible cambiar la fecha de modificación 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>Ejemplo #2 Ejemplo con <span class="function"><strong>touch()</strong></span> utilizando el parámetro
    <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 /> * Esta es la fecha y hora del último acceso, le añadimos 1 hora<br /> * en el pasado.<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">/* ¡Toquemos el fichero! */<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">'¡Ups, ha ocurrido un error...'</span><span style="color: #007700">;<br />} else {<br />    echo </span><span style="color: #DD0000">'La llamada a la función touch() ha tenido éxito'</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">Notas</h3>
  <blockquote class="note"><p><strong class="note">Nota</strong>: <p class="para">
 Tenga en cuenta que la precisión temporal puede variar según el sistema de archivos utilizado.
</p></p></blockquote>
 </div>


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