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 nameSYNOPSISstring tempnam (string $dir, string $prefix)DESCRIPTIONCreates 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.PARAMETERSo $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 VALUESReturns 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. | | | | +--------+---------------------------------------------------+EXAMPLESExample #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); ?>NOTESNote 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 ALSOtmpfile(3), sys_get_temp_dir(3), unlink(3). PHP Documentation Group TEMPNAM(3)
Related Man Pages |
---|
tempnam(3) - centos |
tempnam(3) - linux |
tempnam(3p) - suse |
tempnam(3) - minix |
tempnam(3) - v7 |