Current Location: Home> Function Categories> tempnam

tempnam

Create a file with a unique file name
Name:tempnam
Category:File system
Programming Language:php
One-line Description:Create a unique temporary file.

Definition and usage

tempnam() function creates a temporary file with a unique file name.

If successful, the function returns the new temporary file name. If it fails, return false.

Example

 <?php
echo tempnam ( "C:\inetpub\testweb" , "TMP0" ) ;
?>

Output:

 C:\inetpub\testweb\TMP1.tmp

grammar

 tempnam ( dir , prefix )
parameter describe
dir Required. Specifies the directory where temporary files are created.
prefix Required. Specify the beginning of the file name.

illustrate

Create a file with a unique file name in the specified directory. If the directory does not exist, tempnam() will generate a file in the system temporary directory and return its file name.

Prior to PHP 4.0.6, the behavior of tempnam() function depends on the system. In Windows, the TMP environment variable will pass the dir parameter, in Linux, the TMPDIR environment variable will take precedence, while in SVR4, the dir parameter is always used if the directory it points to exist.

Similar Functions
Popular Articles