English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

PHP tempnam() Function Usage and Example

PHP Filesystem Reference Manual

The tempnam() function can create a temporary file with a unique filename in the specified directory and return the new temporary filename (with path), or return false on failure.

Syntax

string tempnam ( string $dir, string $prefix )

This function can create a file with a unique filename and set the access permissions to 0 in the specified directory600. If the directory does not exist or is not writable, the tempnam() function may generate a file in the system's temporary directory and return the complete path (including the name) of the file.

Online Example

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

Output Result

C:\PhpProject\TMPABFA.tmp
 
PHP Filesystem Reference Manual