Latest web development tutorials

PHP tempnam () function

PHP Filesystem Reference Manual Complete PHP Filesystem Reference Manual

Definition and Usage

tempnam () function is created in the specified directory with a unique file name for temporary files.

This function returns a new temporary file name, if it fails it returns FALSE.

grammar

tempnam(dir,prefix)

参数 描述
dir 必需。规定创建临时文件的目录。
prefix 必需。规定文件名的开头。


Tips and Notes

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

Tip: See also tmpfile ().


Examples

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

The code above will output:

C:inetpubtestwebTMP1.tmp


PHP Filesystem Reference Manual Complete PHP Filesystem Reference Manual