php man page for tempnam

Query: tempnam

OS: php

Section: 3

Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar

TEMPNAM(3)								 1								TEMPNAM(3)

tempnam - Create file with unique file name

SYNOPSIS
string tempnam (string $dir, string $prefix)
DESCRIPTION
Creates a file with a unique filename, with access permission set to 0600, in the specified directory. If the directory does not exist or is not writable, tempnam(3) may generate a file in the system's temporary directory, and return the full path to that file, including its name.
PARAMETERS
o $dir - The directory where the temporary filename will be created. o $prefix - The prefix of the generated temporary filename. Note Windows uses only the first three characters of prefix.
RETURN VALUES
Returns the new temporary filename (with path), or FALSE on failure.
CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 4.0.3 | | | | | | | 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 gener- | | | ated and before the script gets around to creat- | | | ing the file. Note, that you need to remove the | | | file in case you need it no more, it is not done | | | automatically. | | | | +--------+---------------------------------------------------+
EXAMPLES
Example #1 tempnam(3) example <?php $tmpfname = tempnam("/tmp", "FOO"); $handle = fopen($tmpfname, "w"); fwrite($handle, "writing to tempfile"); fclose($handle); // do here something unlink($tmpfname); ?>
NOTES
Note If PHP cannot create a file in the specified $dir parameter, it falls back on the system default. On NTFS this also happens if the specified $dir contains more than 65534 files.
SEE ALSO
tmpfile(3), sys_get_temp_dir(3), unlink(3). PHP Documentation Group TEMPNAM(3)
Related Man Pages
tempnam(3) - redhat
tempnam(3) - debian
tempnam(3) - opendarwin
tempnam(3) - plan9
tempnam(3) - x11r4
Similar Topics in the Unix Linux Community
remove filename prefix
checking parameter values passed to script
remove temporary file ?
how to replace &quot;cd.h&quot; to &lt;cd.h&gt; in a dir
How to remove the first line of a file without using any temporary file