File: tempnam.xml

package info (click to toggle)
php-doc 20081024-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 57,752 kB
  • ctags: 3,858
  • sloc: xml: 686,554; php: 19,446; perl: 610; cpp: 500; makefile: 336; sh: 114; awk: 28
file content (164 lines) | stat: -rw-r--r-- 4,314 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.15 $ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.tempnam">
 <refnamediv>
  <refname>tempnam</refname>
  <refpurpose>Create file with unique file name</refpurpose>
 </refnamediv>
 
 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type>string</type><methodname>tempnam</methodname>
   <methodparam><type>string</type><parameter>dir</parameter></methodparam>
   <methodparam><type>string</type><parameter>prefix</parameter></methodparam>
  </methodsynopsis>
  <para>
   Creates a file with a unique filename, with access permission set to 0600, in the specified directory.
   If the directory does not exist, <function>tempnam</function> may
   generate a file in the system's temporary directory, and return
   the name of that.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>dir</parameter></term>
     <listitem>
      <para>
       The directory where the temporary filename will be created.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>prefix</parameter></term>
     <listitem>
      <para>
       The prefix of the generated temporary filename.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>
 
 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   Returns the new temporary filename, or &false; on
   failure.
  </para>
 </refsect1>

 <refsect1 role="changelog">
  &reftitle.changelog;
  <para>
   <informaltable>
    <tgroup cols="2">
     <thead>
      <row>
       <entry>&Version;</entry>
       <entry>&Description;</entry>
      </row>
     </thead>
     <tbody>
      <row>
       <entry>4.0.6</entry>
       <entry>
        Prior to PHP 4.0.6, the behaviour of the
        <function>tempnam</function> function was system dependent. On
        Windows the TMP environment variable will override the
        <parameter>dir</parameter> parameter, on Linux the TMPDIR
        environment variable has precedence, while SVR4 will always use
        your <parameter>dir</parameter> parameter if the directory it
        points to exists. Consult your system documentation on the
        tempnam(3) function if in doubt.
       </entry>
      </row>
      <row>
       <entry>4.0.3</entry>
       <entry>
        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 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.
       </entry>
      </row>
     </tbody>
    </tgroup>
   </informaltable>
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title><function>tempnam</function> example</title>
    <programlisting role="php">
<![CDATA[
<?php
$tmpfname = tempnam("/tmp", "FOO");

$handle = fopen($tmpfname, "w");
fwrite($handle, "writing to tempfile");
fclose($handle);

// do here something

unlink($tmpfname);
?>
]]>
    </programlisting>
   </example>
  </para>
 </refsect1>

 <refsect1 role="notes">
  &reftitle.notes;
  <note>
   <simpara>
    If PHP cannot create a file in the specified <parameter>dir</parameter>
    parameter, it falls back on the system default.
   </simpara>
  </note>
 </refsect1>
 
 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><function>tmpfile</function></member>
    <member><function>sys_get_temp_dir</function></member>
    <member><function>unlink</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:"../../../../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
-->