PHP tempnam() Function

PHP tmpfile() Function
PHP symlink() Function

In this article, you will learn how to create a temporary file in PHP. The tempnam() function in PHP creates a temporary file with a unique name in the specified directory. It creates a file in the system temporary directory if the specified directory does not exist.

what is the syntax of the TEMPNAM function in php?

tempnam(dir, prefix)
ParameterDescription
dirRequired. Specifies the directory of where to create the temp file
prefixRequired. Specifies the start of the filename
PHP TEMPNAM() method

examples of the TEMPNAM function

Example 1. In this example, we create a temporary file with a unique name in the specified directory.

<?php
echo tempnam("C:\inetpub\testweb","TMP0");
?>
PHP tmpfile() Function
PHP symlink() Function

Stay up-to-date about PHP!

We don’t spam!

en English
X
Scroll to Top