PHP tempnam() Function
❮ PHP Filesystem ReferenceExample
Create a temporary file with a unique name in the specified directory:
<?php
echo tempnam("C:\inetpub\testweb","TMP0");
?>
The output of the code above could be:
C:\inetpub\testweb\TMP1.tmp
Definition and Usage
The tempnam() function creates a temporary file with a unique name in the specified directory.
Note: If the specified directory does not exist, tempnam() may generate a file in the system's temporary directory.
Tip: See also the tmpfile() function.
Syntax
tempnam(dir, prefix)
Parameter Values
Parameter | Description |
---|---|
dir | Required. Specifies the directory of where to create the temp file |
prefix | Required. Specifies the start of the filename |
Technical Details
Return Value: | The new temporary filename, FALSE on failure |
---|---|
PHP Version: | 4.0+ |
PHP Changelog: |
❮ PHP Filesystem Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.