goba Thu Nov 22 17:15:16 2001 EDT
Modified files:
/phpdoc/en/functions filesystem.xml
Log:
Some clarification on tempnam and tmpfile, example addded
to tmpfile, unlink() added to tempnam.
Index: phpdoc/en/functions/filesystem.xml
diff -u phpdoc/en/functions/filesystem.xml:1.89 phpdoc/en/functions/filesystem.xml:1.90
--- phpdoc/en/functions/filesystem.xml:1.89 Thu Nov 22 12:50:57 2001
+++ phpdoc/en/functions/filesystem.xml Thu Nov 22 17:15:13 2001
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.89 $ -->
+<!-- $Revision: 1.90 $ -->
<reference id="ref.filesystem">
<title>Filesystem functions</title>
<titleabbrev>Filesystem</titleabbrev>
@@ -2801,7 +2801,8 @@
<para>
Creates a file with a unique filename in the specified directory.
If the directory does not exist, <function>tempnam</function> may
- generate a filename in the system's temporary directory.
+ generate a file in the system's temporary directory, and return
+ the name of it.
</para>
<para>
Prior to PHP 4.0.6, the behaviour of the
@@ -2821,6 +2822,14 @@
<programlisting role="php">
<![CDATA[
$tmpfname = tempnam ("/tmp", "FOO");
+
+$fp = fopen($tmpfname, "w");
+fwrite($fp, "writing to tempfile");
+fclose($fp);
+
+// do here something
+
+unlink($tmpfname);
]]>
</programlisting>
</example>
@@ -2830,11 +2839,13 @@
This function's behavior changed in 4.0.3. The temporary file is also
created to avoid a race condition where the file might appear in the
filesystem between the time the string was generated and before the
- the script gets around to creating the file.
+ the script gets around to creating the file. Note, that you need
+ to remove the file in case you need it no more, it is not done
+ automatically.
</simpara>
</note>
<para>
- See also <function>tmpfile</function>.
+ See also <function>tmpfile</function>, <function>unlink</function>.
</para>
</refsect1>
</refentry>
@@ -2863,6 +2874,18 @@
For details, consult your system documentation on the
<literal>tmpfile(3)</literal> function, as well as the
<filename>stdio.h</filename> header file.
+ </para>
+ <para>
+ <example>
+ <title><function>tmpfile</function> example</title>
+ <programlisting role="php">
+<![CDATA[
+$temp = tmpfile();
+fwrite($temp, "writing to tempfile");
+fclose($temp); // this removes the file
+]]>
+ </programlisting>
+ </example>
</para>
<para>
See also <function>tempnam</function>.