<?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.tempnam.php',
    1 => 'tempnam',
    2 => 'Crea un fichero con un nombre &uacute;nico',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => 'Funciones del Sistema de Archivos',
  ),
  'prev' => 
  array (
    0 => 'function.symlink.php',
    1 => 'symlink',
  ),
  'next' => 
  array (
    0 => 'function.tmpfile.php',
    1 => 'tmpfile',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'es',
    'path' => 'reference/filesystem/functions/tempnam.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.tempnam" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">tempnam</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">tempnam</span> &mdash; <span class="dc-title">Crea un fichero con un nombre único</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.tempnam-description">
  <h3 class="title">Descripción</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>tempnam</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$directory</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$prefix</code></span>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   Crea un fichero con un nombre único, con permisos de acceso 0600,
   en el directorio especificado. Si el directorio no existe o no es accesible en escritura,
   <span class="function"><strong>tempnam()</strong></span> intentará crear un fichero en el directorio
   temporal del sistema, y devolverá la ruta completa de dicho fichero, incluyendo su
   nombre.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.tempnam-parameters">
  <h3 class="title">Parámetros</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">directory</code></dt>
     <dd>
      <p class="para">
       El directorio en el que se creará el fichero temporal.
      </p>
     </dd>
    
    
     <dt><code class="parameter">prefix</code></dt>
     <dd>
      <p class="para">
       El prefijo del fichero temporal generado.
      </p>
      <blockquote class="note"><p><strong class="note">Nota</strong>: 
       <span class="simpara">
        Solo se utilizan los 63 primeros caracteres del prefijo, el resto se ignora.
        Windows utiliza únicamente los 3 primeros caracteres del prefijo.
       </span>
      </p></blockquote>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.tempnam-returnvalues">
  <h3 class="title">Valores devueltos</h3>
  <p class="para">
   Devuelve un nuevo fichero temporal (con su ruta), 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.tempnam-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>7.1.0</td>
      <td>
       <span class="function"><strong>tempnam()</strong></span> ahora emite un aviso al recurrir al directorio temporal del sistema.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.tempnam-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>tempnam()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$tmpfname </span><span style="color: #007700">= </span><span style="color: #0000BB">tempnam</span><span style="color: #007700">(</span><span style="color: #DD0000">"/tmp"</span><span style="color: #007700">, </span><span style="color: #DD0000">"FOO"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$handle </span><span style="color: #007700">= </span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #0000BB">$tmpfname</span><span style="color: #007700">, </span><span style="color: #DD0000">"w"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">fwrite</span><span style="color: #007700">(</span><span style="color: #0000BB">$handle</span><span style="color: #007700">, </span><span style="color: #DD0000">"Escritura en el fichero temporal"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$handle</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// procesamiento<br /><br /></span><span style="color: #0000BB">unlink</span><span style="color: #007700">(</span><span style="color: #0000BB">$tmpfname</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 notes" id="refsect1-function.tempnam-notes">
  <h3 class="title">Notas</h3>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
   <span class="simpara">
    Si PHP no puede crear un fichero en el directorio especificado por el argumento
    <code class="parameter">directory</code>, intentará hacerlo en el directorio por defecto del sistema.
    En sistemas de archivos NTFS, esto también ocurre si el directorio
    <code class="parameter">directory</code> contiene más de 65534 ficheros.
   </span>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.tempnam-seealso">
  <h3 class="title">Ver también</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.tmpfile.php" class="function" rel="rdfs-seeAlso">tmpfile()</a> - Crea un fichero temporal</span></li>
    <li><span class="function"><a href="function.sys-get-temp-dir.php" class="function" rel="rdfs-seeAlso">sys_get_temp_dir()</a> - Devuelve la ruta del directorio utilizado para los ficheros temporales</span></li>
    <li><span class="function"><a href="function.unlink.php" class="function" rel="rdfs-seeAlso">unlink()</a> - Elimina un fichero</span></li>
   </ul>
  </p>
 </div>


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