PHP is_writeable 存在bug , 写一个自定函数 判断文件是否可写

$is_w = function($file){
if(DIRECTORY_SEPARATOR == '/' and @ini_get('safe_mode')==false){
return is_writable($file);
}
if(is_dir($file))
{
$file = rtrim($file,'/').'/'.md5(mt_rand(1,100).mt_rand(1,1000));
if(($fp = @fopen($file,'w') == false)){
return false;
}
fclose($fp);
@chmod($file,0777);
@unlink($file);
return true;
}elseif(!is_file() or ($fp=fopen($file,'w')) == false)
{
return false;
}
};
原文地址:https://www.cnblogs.com/musings/p/7701012.html