Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 6283

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Creates a temporary file</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.tempnam.html">tempnam</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.touch.html">touch</a></div>
 <div class="up"><a href="ref.filesystem.html">Filesystem Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.tmpfile" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">tmpfile</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">tmpfile</span> &mdash; <span class="dc-title">Creates a temporary file</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.tmpfile-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">resource</span> <span class="methodname"><strong>tmpfile</strong></span>
    ( <span class="methodparam">void</span>
   )</div>

  <p class="para rdfs-comment">
   Creates a temporary file with a unique name in read-write (w+) mode and
   returns a file handle .
  </p>
  <p class="para">
   The file is automatically removed when closed (for example, by calling
    <span class="function"><a href="function.fclose.html" class="function">fclose()</a></span>, or when there are no remaining references to
   the file handle returned by  <span class="function"><strong>tmpfile()</strong></span>), or when the
   script ends.
  </p>
  <p class="para">
   For details, consult your system documentation on the
   <em>tmpfile(3)</em> function, as well as the
   <var class="filename">stdio.h</var> header file.
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.tmpfile-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a file handle, similar to the one returned by
    <span class="function"><a href="function.fopen.html" class="function">fopen()</a></span>, for the new file or <strong><code>FALSE</code></strong> on failure.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.tmpfile-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-2435">
    <p><strong>Example #1  <span class="function"><strong>tmpfile()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$temp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">tmpfile</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">fwrite</span><span style="color: #007700">(</span><span style="color: #0000BB">$temp</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"writing&nbsp;to&nbsp;tempfile"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">fseek</span><span style="color: #007700">(</span><span style="color: #0000BB">$temp</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">fread</span><span style="color: #007700">(</span><span style="color: #0000BB">$temp</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1024</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$temp</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;this&nbsp;removes&nbsp;the&nbsp;file<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
writing to tempfile
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.tmpfile-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.tempnam.html" class="function" rel="rdfs-seeAlso">tempnam()</a> - Create file with unique file name</span></li>
    <li class="member"> <span class="function"><a href="function.sys-get-temp-dir.html" class="function" rel="rdfs-seeAlso">sys_get_temp_dir()</a> - Returns directory path used for temporary files</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.tempnam.html">tempnam</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.touch.html">touch</a></div>
 <div class="up"><a href="ref.filesystem.html">Filesystem Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>