2016-08-25 55 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

更新了这个问题作为答案! –