2010-03-28 22:10:10 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2009-07-11 07:05:15 +00:00
|
|
|
<!-- $Revision$ -->
|
2007-06-20 22:25:43 +00:00
|
|
|
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.tempnam">
|
2007-02-03 08:13:44 +00:00
|
|
|
<refnamediv>
|
|
|
|
<refname>tempnam</refname>
|
|
|
|
<refpurpose>Create file with unique file name</refpurpose>
|
|
|
|
</refnamediv>
|
2007-09-15 02:44:00 +00:00
|
|
|
|
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
2007-02-03 08:13:44 +00:00
|
|
|
<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>
|
2007-02-04 16:14:18 +00:00
|
|
|
Creates a file with a unique filename, with access permission set to 0600, in the specified directory.
|
2015-06-14 15:20:45 +00:00
|
|
|
If the directory does not exist or is not writable, <function>tempnam</function> may
|
2007-02-03 08:13:44 +00:00
|
|
|
generate a file in the system's temporary directory, and return
|
2014-03-29 21:52:46 +00:00
|
|
|
the full path to that file, including its name.
|
2007-02-03 08:13:44 +00:00
|
|
|
</para>
|
2007-09-15 02:44:00 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="parameters">
|
|
|
|
&reftitle.parameters;
|
2007-02-03 08:13:44 +00:00
|
|
|
<para>
|
2007-09-15 02:44:00 +00:00
|
|
|
<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>
|
2008-11-07 11:35:03 +00:00
|
|
|
<note>
|
|
|
|
<simpara>
|
2010-01-03 21:47:22 +00:00
|
|
|
Windows uses only the first three characters of prefix.
|
2008-11-07 11:35:03 +00:00
|
|
|
</simpara>
|
|
|
|
</note>
|
2007-09-15 02:44:00 +00:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
2007-02-03 08:13:44 +00:00
|
|
|
</para>
|
2007-09-15 02:44:00 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
&reftitle.returnvalues;
|
2007-02-03 08:13:44 +00:00
|
|
|
<para>
|
2014-03-29 21:52:46 +00:00
|
|
|
Returns the new temporary filename (with path), or &false; on
|
2007-02-03 08:13:44 +00:00
|
|
|
failure.
|
2007-09-15 02:44:00 +00:00
|
|
|
</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.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>
|
2007-02-03 08:13:44 +00:00
|
|
|
<example>
|
|
|
|
<title><function>tempnam</function> example</title>
|
|
|
|
<programlisting role="php">
|
2002-04-15 00:12:54 +00:00
|
|
|
<![CDATA[
|
2003-05-30 20:43:26 +00:00
|
|
|
<?php
|
2003-12-15 16:55:22 +00:00
|
|
|
$tmpfname = tempnam("/tmp", "FOO");
|
2002-04-15 00:12:54 +00:00
|
|
|
|
2003-01-13 02:54:28 +00:00
|
|
|
$handle = fopen($tmpfname, "w");
|
|
|
|
fwrite($handle, "writing to tempfile");
|
|
|
|
fclose($handle);
|
2002-04-15 00:12:54 +00:00
|
|
|
|
|
|
|
// do here something
|
|
|
|
|
|
|
|
unlink($tmpfname);
|
2003-05-30 20:43:26 +00:00
|
|
|
?>
|
2002-04-15 00:12:54 +00:00
|
|
|
]]>
|
2007-02-03 08:13:44 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
2007-09-15 02:44:00 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="notes">
|
|
|
|
&reftitle.notes;
|
2007-02-03 08:13:44 +00:00
|
|
|
<note>
|
|
|
|
<simpara>
|
2007-09-15 02:44:00 +00:00
|
|
|
If PHP cannot create a file in the specified <parameter>dir</parameter>
|
2009-04-21 02:52:46 +00:00
|
|
|
parameter, it falls back on the system default. On NTFS this also happens
|
|
|
|
if the specified <parameter>dir</parameter> contains more than 65534 files.
|
2007-02-03 08:13:44 +00:00
|
|
|
</simpara>
|
|
|
|
</note>
|
2007-09-15 02:44:00 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
2007-02-03 08:13:44 +00:00
|
|
|
<para>
|
2007-09-15 02:44:00 +00:00
|
|
|
<simplelist>
|
|
|
|
<member><function>tmpfile</function></member>
|
|
|
|
<member><function>sys_get_temp_dir</function></member>
|
|
|
|
<member><function>unlink</function></member>
|
|
|
|
</simplelist>
|
2007-02-03 08:13:44 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
2007-09-15 02:44:00 +00:00
|
|
|
|
2007-02-03 08:13:44 +00:00
|
|
|
</refentry>
|
2002-04-15 00:12:54 +00:00
|
|
|
|
|
|
|
<!-- 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
|
2009-09-25 07:04:39 +00:00
|
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
2002-04-15 00:12:54 +00:00
|
|
|
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
|
|
|
|
-->
|