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.