Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<set_time_limitversion_compare>
^PHP Options/Info FunctionsLast updated: Mon, 26 Oct 2026

sys_get_temp_dir

(PHP 5 >= 5.2.1, PHP 7, PHP 8)

sys_get_temp_dir — Returns directory path used for temporary files

Description

function sys_get_temp_dir(): string

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

Parameters

This function has no parameters.

Return Values

Returns the path of the temporary directory.

Examples

Example #1 sys_get_temp_dir() example

<?php
// 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;
?>

The above example will output something similar to:

C:\Windows\Temp\TuxA318.tmp

See Also


<set_time_limitversion_compare>
^PHP Options/Info FunctionsLast updated: Mon, 26 Oct 2026