note 94119 deleted from function.sys-get-temp-dir by danbrown
| From: | danbrown@php.net | Date: | Tue, 23 Jul 2013 13:50:30 +0000 |
| Subject: | note 94119 deleted from function.sys-get-temp-dir by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-195730@lists.php.net to get a copy of this message | ||
Note Submitter: php at ktools.eu
----
-better to use the php methode 'getenv()' to access the enviroment vars
-the original 'sys_get_temp_dir()' don't use realpath, than it's better to make
'realpath(sys_get_temp_dir())'
<?php
if ( !function_exists('sys_get_temp_dir')) {
function sys_get_temp_dir() {
if( $temp=getenv('TMP') ) return $temp;
if( $temp=getenv('TEMP') ) return $temp;
if( $temp=getenv('TMPDIR') ) return $temp;
$temp=tempnam(__FILE__,'');
if (file_exists($temp)) {
unlink($temp);
return dirname($temp);
}
return null;
}
}
echo realpath(sys_get_temp_dir());
?>