Phpsys_get_temp_dir-returned temporary file path _ PHP Tutorial

Source: Internet
Author: User
Phpsys_get_temp_dir-return the temporary file path. Let's take a look at phpsys_get_temp_dir-how to use the function to return the temporary file path and how it works. Sys_get_temp_dir (5.2.1 in PHP5) has been paid. you need not to mention more. let's take a look at the usage and implementation principles of the function returned to the temporary file path in php sys_get_temp_dir.

Sys_get_temp_dir
("= 5.2.1" in PHP 5)

Let's take a look at the usage and implementation principles of the php sys_get_temp_dir-return temporary file path function.

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

// 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:

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

Sys_get_temp_dir-return the usage and implementation principles of the temporary file path function. Sys_get_temp_dir (PHP 5 = 5.2.1) paid...

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.