note 85261 deleted from function.sys-get-temp-dir by danbrown

From: Date: Tue, 23 Jul 2013 13:50:39 +0000
Subject: note 85261 deleted from function.sys-get-temp-dir by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-195731@lists.php.net to get a copy of this message
Note Submitter: php [spat] hm2k.org ---- I went ahead and slightly improved the function provided. <?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)); } } } ?>

« previous php.notes (#195731) next »