2016-08-25 42 views
-5

任何人都知道在PHP替代品PHP老版本的功能

sys_get_temp_dirDIRECTORY_SEPARATORtempnam替代功能現有的PHP版本是4 *

+2

只是...什麼?爲什麼? –

+0

我們在服務器上安裝了PHP的舊版本,所以我無法找到從ini_get()中讀取系統臨時目錄路徑 –

+0

的替代方法? – Robert

回答

1

中的tempnam PHP4

You can use this code from php.net to get a temp dir:

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(__FILE__,''); 
    if (file_exists($tempfile)) { 
     unlink($tempfile); 
     return realpath(dirname($tempfile)); 
    } 
    return null; 
    } 
} 
存在
+0

謝謝你們......!它的工作在我們的服務器上,即使它的-32投票在http://php.net/manual/en/function.sys-get-temp-dir.php#93390 –

+0

我不知道爲什麼人們投了票-ve –

+0

更新了這個問題作爲答案! –