Sys_get_temp_dir
("= 5.2.1" in PHP 5)
Sys_get_temp_dir-the returned directory path is used for temporary files.
Description
String sys_get_temp_dir (invalid)
The PHP store temporary files in the returned directory path are used by default.
Return value
The temporary directory of the returned path.
Instance
Example #1 sys_get_temp_dir ()
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:
C: WindowsTempTuxA318.tmp
Implementation of this function:
<? Php
If (! Function_exists ('sys _ get_temp_dir ')){
Function sys_get_temp_dir (){
If (! Empty ($ _ ENV ['tmp ']) {return realpath ($ _ ENV ['tmp']);}
If (! Empty ($ _ ENV ['tmpdir']) {return realpath ($ _ ENV ['tmpdir']);}
If (! Empty ($ _ ENV ['temp ']) {return realpath ($ _ ENV ['temp']);}
$ Tempfile = tempnam (uniqid (rand (), TRUE ),'');
If (file_exists ($ tempfile )){
Unlink ($ tempfile );
Return realpath (dirname ($ tempfile ));
}
}
}
?>