PHP Function Tempnam
php function tempnam is used to create a temporary file with unique name in the specified directory. If the specified directory does not exist or is not writable, the function will generate a file in the system temporary directory and return the full path to that file including its name.
Unlike a regular file created with tmpfile, a tempnam file only exists during the execution of a script and is automatically deleted when the script ends. This can be useful if you want to avoid the problem of programs leaving behind temporary files that may accumulate over time and consume large amounts of disk space.
The php function tempnam takes two parameters, dir and prefix. The first is the directory where the temporary file will get created. The second is the starting point of the filename. The default value is '', so the first part of the filename will be prefixed by the current umask value (which is the combination of all of the user permission bits) if it is not set explicitly.
The function returns the new temporary filename (with path) or false on failure. The unique filename it creates has its access permissions set to 0600, which is the same as for a regular file created by tmpfile.
The behavior of this function can vary depending on your operating system, since the default value is the directory specified by your TMPDIR environment variable on Unix or TMP environment variable on Windows. It is best to consult your system documentation if you need more information about the behavior of this function.