<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.tmpfile">
 <refnamediv>
  <refname>tmpfile</refname>
  <refpurpose>Creates a temporary file</refpurpose>
 </refnamediv>
 
 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type>resource</type><methodname>tmpfile</methodname>
   <void/>
  </methodsynopsis>
  <para>
   Creates a temporary file with a unique name in read-write (w+) mode and
   returns a file handle .
  </para>
  <para>
   The file is automatically removed when closed (for example, by calling
   <function>fclose</function>, or when there are no remaining references to
   the file handle returned by <function>tmpfile</function>), or when the
   script ends.
  </para>
  <para>
   For details, consult your system documentation on the
   <literal>tmpfile(3)</literal> function, as well as the
   <filename>stdio.h</filename> header file.
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   Returns a file handle, similar to the one returned by
   <function>fopen</function>, for the new file&return.falseforfailure;.
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title><function>tmpfile</function> example</title>
    <programlisting role="php">
<![CDATA[
<?php
$temp = tmpfile();
fwrite($temp, "writing to tempfile");
fseek($temp, 0);
echo fread($temp, 1024);
fclose($temp); // this removes the file
?>
]]>
    </programlisting>
    &example.outputs;
    <screen>
<![CDATA[
writing to tempfile
]]>
    </screen>
   </example>
  </para>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><function>tempnam</function></member>
    <member><function>sys_get_temp_dir</function></member>
   </simplelist>
  </para>
 </refsect1>

</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->