PHP tempnam() Function
In this chapter you will learn:
- Definition for PHP tempnam() Function
- Syntax for PHP tempnam() Function
- Parameter for PHP tempnam() Function
- Return for PHP tempnam() Function
- Note for PHP tempnam() Function
- Example - Creates a temporary file with a unique filename in the specified directory
Definition
The tempnam() function creates a temporary file with a unique filename in the specified directory.
Syntax
PHP tempnam() Function has the following syntax.
tempnam(dir,prefix)
Parameter
Parameter | Is Required | Description |
---|---|---|
dir | Required. | Directory of where to create the temp file |
prefix | Required. | Start of the filename |
Return
This function returns the new temporary filename, or FALSE on failure.
Note
If the specified directory does not exist, tempnam() may generate a file in the system's temporary directory.
Example
<?php
echo tempnam("C:\test\testweb","TMP0");
?>
Next chapter...
What you will learn in the next chapter:
- Definition for PHP tmpfile() Function
- Syntax for PHP tmpfile() Function
- Return for PHP tmpfile() Function
- Note for PHP tmpfile() Function
- Example - Create a temporary file and write and read
Home » PHP Tutorial » PHP File Functions