sys_get_temp_dir()

sys_get_temp_dir() — Returns directory path used for temporary files.

Built-in function of PHP 8.5. The manual lists it as available in PHP 5 >= 5.2.1, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

What it does

Returns the path of the directory PHP stores temporary files in by default.

Signature

sys_get_temp_dir(): string

Parameters

This function takes no parameters.

Return value

Returns the path of the temporary directory.

Example

A runnable snippet:

// Create a temporary file in the temporary // files directory using sys_get_temp_dir() $temp_file = tempnam(sys_get_temp_dir(), 'Tux'); echo $temp_file;

Output:

C:\Windows\Temp\TuxA318.tmp

See also

tmpfile(), tempnam()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page sys_get_temp_dir() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.