PHP sys_get_temp_dir() Function Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The sys_get_temp_dir() is an inbuilt function where the directory path for temporary files will be returned. Syntax: sys_get_temp_dir()Parameter: This function doesn't accept any parameter. Return Value: This function returns the path for the temporary directory. Example 1: This code demonstrates the sys_get_temp_dir() function. PHP <?php // print tmp location echo sys_get_temp_dir(); ?> Output: /tmp Example 2: This is another code that demonstrates the sys_get_temp_dir() function. PHP <?php $temp_file = tempnam(sys_get_temp_dir(), 'gfg'); echo $temp_file; ?> Output: /tmp/gfgluzYqw Reference: https://www.php.net/manual/en/function.sys-get-temp-dir.php Create Quiz Comment N neeraj3304 Follow 0 Improve N neeraj3304 Follow 0 Improve Article Tags : PHP PHP-function PHP-Options-info Explore BasicsPHP Syntax4 min readPHP Variables5 min readPHP | Functions6 min readPHP Loops4 min readArrayPHP Arrays5 min readPHP Associative Arrays4 min readMultidimensional arrays in PHP5 min readSorting Arrays in PHP4 min readOOPs & InterfacesPHP Classes2 min readPHP | Constructors and Destructors5 min readPHP Access Modifiers4 min readMultiple Inheritance in PHP4 min readMySQL DatabasePHP | MySQL Database Introduction4 min readPHP Database connection2 min readPHP | MySQL ( Creating Database )3 min readPHP | MySQL ( Creating Table )3 min readPHP AdvancePHP Superglobals6 min readPHP | Regular Expressions12 min readPHP Form Handling4 min readPHP File Handling4 min readPHP | Uploading File3 min readPHP Cookies9 min readPHP | Sessions7 min read Like