Php sys_get_temp_dir-returned temporary file path

Source: Internet
Author: User

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 ));
    }
  }
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.