Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

tempnam()

Example

Create a temporary file with a unique name in the specified directory.

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

The result of the code above might be:

C:\inetpub\testweb\TMP1.tmp

Definition and Usage

The tempnam() function creates a temporary file with a unique name in the given directory.

Note: If the specified directory does not exist, tempnam() may create the file in the system’s temporary directory.

 

Tip: Also consider using the tmpfile() function.

Syntax

tempnam(dirprefix)

Parameter Values

 

Parameter

Description

dir

Required. Specifies the directory in which to create the temporary file.

prefix

Required. Specifies the prefix for the filename.

Technical Details

Return Value:

Returns the new temporary filename on success; FALSE on failure.

PHP Version:

4.0+

PHP Changelog:

Returns the new temporary filename on success; FALSE on failure.