<?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 => 'pt_BR',
  ),
  'this' => 
  array (
    0 => 'function.tempnam.php',
    1 => 'tempnam',
    2 => 'Cria arquivo com nome &uacute;nico',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => 'Fun&ccedil;&otilde;es de Filesystem',
  ),
  'prev' => 
  array (
    0 => 'function.symlink.php',
    1 => 'symlink',
  ),
  'next' => 
  array (
    0 => 'function.tmpfile.php',
    1 => 'tmpfile',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'pt_BR',
    '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">Cria arquivo com nome único</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.tempnam-description">
  <h3 class="title">Descrição</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">
   Cria um arquivo com nome único, com permissões de acesso definidas para 0600, no diretório
   especificado. Se o diretório não existir ou não puder ser escrito, <span class="function"><strong>tempnam()</strong></span> pode
   gerar um arquivo no diretório temporário do sistema e retornar
   o caminho completo ao arquivo, incluindo seu nome.
  </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">
       O diretório onde o arquivo temporário será criado.
      </p>
     </dd>
    
    
     <dt><code class="parameter">prefix</code></dt>
     <dd>
      <p class="para">
       O prefixo do nome do arquivo temporário gerado.
      </p>
      <blockquote class="note"><p><strong class="note">Nota</strong>: 
       <span class="simpara">
        Apenas os primeiros 63 caracteres do prefixo são usados, o restante é ignorado.
        Windows usa apenas os primeiros três caracteres do prefixo.
       </span>
      </p></blockquote>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.tempnam-returnvalues">
  <h3 class="title">Valor Retornado</h3>
  <p class="para">
   Retorna o novo nome do arquivo temporário (com caminho), ou <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> em
   caso de falha.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.tempnam-changelog">
  <h3 class="title">Registro de Alterações</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Versão</th>
      <th>Descrição</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>7.1.0</td>
      <td>
       <span class="function"><strong>tempnam()</strong></span> agora emite um aviso ao cair de volta
       no diretório temporário do sistema.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.tempnam-examples">
  <h3 class="title">Exemplos</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemplo #1 Exemplo de <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">"writing to tempfile"</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">// faz alguma coisa<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">
    Se o PHP não conseguir criar um arquivo no diretório informado <code class="parameter">directory</code>,
    ele cria no diretório padrão do sistema. No sistema de arquivos NTFS isto também acontece
    se o diretório especificado em <code class="parameter">directory</code> contiver mais que 65534 arquivos.
   </span>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.tempnam-seealso">
  <h3 class="title">Veja Também</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.tmpfile.php" class="function" rel="rdfs-seeAlso">tmpfile()</a> - Cria um arquivo tempor&aacute;rio</span></li>
    <li><span class="function"><a href="function.sys-get-temp-dir.php" class="function" rel="rdfs-seeAlso">sys_get_temp_dir()</a> - Retorna o caminho do diret&oacute;rio usado para arquivos tempor&aacute;rios</span></li>
    <li><span class="function"><a href="function.unlink.php" class="function" rel="rdfs-seeAlso">unlink()</a> - Apaga um arquivo</span></li>
   </ul>
  </p>
 </div>


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