好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

php sys_get_temp_dir -返回临时文件路径 - php函数

php sys_get_temp_dir -返回临时文件路径

好了费话不用说多了我们来看看这款php sys_get_temp_dir -返回临时文件路径函数使用方法与实现原理吧.

sys_get_temp_dir -返回目录路径用于临时文件

描述: 字符串sys_get_temp_dir(无效),返回目录路径的PHP商店临时文件在默认情况下.

返回值: 返回路径的临时目录中.

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 to:C:WindowsTempTuxA318.tmp

此函数的实现方法:

if  ( !function_exists( 'sys_get_temp_dir' )) {     function  sys_get_temp_dir() {       if  (! empty empty ( $_ENV [ 'TMP' ])) {  return   realpath ( $_ENV [ 'TMP' ]); }       if  (! empty empty ( $_ENV [ 'TMPDIR' ])) {  return   realpath (  $_ENV [ 'TMPDIR' ]); }       if  (! empty empty ( $_ENV [ 'TEMP' ])) {  return   realpath (  $_ENV [ 'TEMP' ]); }       $tempfile =tempnam(uniqid(rand(),TRUE), '' );       if  ( file_exists ( $tempfile )) {      unlink( $tempfile );       return   realpath (dirname( $tempfile ));      } //开源代码phpfensi测试数据     }  }  ?>

查看更多关于php sys_get_temp_dir -返回临时文件路径 - php函数的详细内容...

  阅读:41次