Current Location: Home> Function Categories> sys_get_temp_dir

sys_get_temp_dir

Return to the directory used for temporary files
Name:sys_get_temp_dir
Category:PHP Options and Information
Programming Language:php
One-line Description:Return to the temporary directory of the operating system

Function name: sys_get_temp_dir()

Applicable version: PHP 5 >= 5.2.1, PHP 7

Function description: sys_get_temp_dir() function returns the temporary directory of the operating system.

usage:

 $tempDir = sys_get_temp_dir();

Example:

 $tempDir = sys_get_temp_dir(); echo "系统临时目录是:" . $tempDir;

Output:

系统临时目录是:/tmp

Notes:

  • The sys_get_temp_dir() function attempts to return the default temporary directory path to the operating system.
  • The location of temporary directories may vary across operating systems.
  • The returned directory path does not contain a slash (/).
  • If the temporary directory path cannot be obtained, the function returns FALSE.

suggestion:

  • When you need to create a temporary file or directory, using the sys_get_temp_dir() function ensures compatibility on different operating systems.
  • When using the returned temporary directory path, it is best to manually add slashes (/) to ensure the correctness of the path.
Similar Functions
Popular Articles