<?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 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.tempnam.php',
    1 => 'tempnam',
    2 => '一意なファイル名を生成する',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => 'ファイルシステム 関数',
  ),
  'prev' => 
  array (
    0 => 'function.symlink.php',
    1 => 'symlink',
  ),
  'next' => 
  array (
    0 => 'function.tmpfile.php',
    1 => 'tmpfile',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    '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">一意なファイル名を生成する</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.tempnam-description">
  <h3 class="title">説明</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">
   一意なテンポラリファイル名を、パーミッションを 0600 に設定し、
   指定したディレクトリに作成します。
   指定したディレクトリが存在しない場合やディレクトリに書き込めない場合は、<span class="function"><strong>tempnam()</strong></span>
   はシステムのテンポラリディレクトリにあるファイル名を生成し、
   そのファイルへのフルパスを (名前を含めて) 返します。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.tempnam-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">directory</code></dt>
     <dd>
      <p class="para">
       テンポラリファイルを作成したいディレクトリ。
      </p>
     </dd>
    
    
     <dt><code class="parameter">prefix</code></dt>
     <dd>
      <p class="para">
       作成されるテンポラリファイルのプレフィックス。
      </p>
      <blockquote class="note"><p><strong class="note">注意</strong>: 
       <span class="simpara">
        プレフィックスの最初の63文字のみを使用し、残りは無視されます。
        Windows では、プレフィックスの最初の 3 文字のみを使用します。
       </span>
      </p></blockquote>
     </dd>
    
   </dl>
  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-function.tempnam-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para">
   新しいテンポラリファイル名 (パスを含む) を返し、失敗した場合には <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> を返します。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.tempnam-changelog">
  <h3 class="title">変更履歴</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>バージョン</th>
      <th>説明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>7.1.0</td>
      <td>
       <span class="function"><strong>tempnam()</strong></span> は、
       システムのテンポラリディレクトリにフォールバックした場合に
       警告を生成するようになりました。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.tempnam-examples">
  <h3 class="title">例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>例1 <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">// ここで何か行う<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">注意</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <span class="simpara">
    PHP が指定されたパラメータ <code class="parameter">directory</code>
    にファイルを生成することができない場合、
    システム標準のフォールバックが実行されます。
    NTFS では、指定した <code class="parameter">directory</code>
    に 65534 を超える数のファイルが存在する場合にも同じことが起こります。
   </span>
  </p></blockquote>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.tempnam-seealso">
  <h3 class="title">参考</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.tmpfile.php" class="function" rel="rdfs-seeAlso">tmpfile()</a> - テンポラリファイルを作成する</span></li>
    <li><span class="function"><a href="function.sys-get-temp-dir.php" class="function" rel="rdfs-seeAlso">sys_get_temp_dir()</a> - 一時ファイル用に使用されるディレクトリのパスを返す</span></li>
    <li><span class="function"><a href="function.unlink.php" class="function" rel="rdfs-seeAlso">unlink()</a> - ファイルを削除する</span></li>
   </ul>
  </p>
 </div>


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