PHP tempnam()Functions


PHP Filesystem 参考手册Complete PHP Filesystem Reference

Definition and Usage

The tempnam() function creates a temporary file with a unique filename in the specified directory.

This function returns the new temporary filename, or FALSE on failure.

Syntax

tempnam(dir,prefix)

Parameters Description
dir Required. Specifies the directory in which to create the temporary file.
prefix Required. Specifies the beginning of the filename.


Tips and Notes

Note:If the specified directory does not exist, tempnam() will generate a file in the system's temporary directory.

Tip:See tmpfile().


Examples

<?php
echo tempnam("C:inetpubtestweb","TMP0");
?>

The code above will output:

C:inetpubtestwebTMP1.tmp


PHP Filesystem 参考手册Complete PHP Filesystem Reference Other Extensions