Skip to content

Instantly share code, notes, and snippets.

@jk2K
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jk2K/9636804 to your computer and use it in GitHub Desktop.
Save jk2K/9636804 to your computer and use it in GitHub Desktop.
测试文件夹是否可写
function dir_writeable($dir) {
$writeable = 0;
if(!is_dir($dir)) {
@mkdir($dir, 0777);
}
if(is_dir($dir)) {
if($fp = @fopen("$dir/test.txt", 'w')) {
@fclose($fp);
@unlink("$dir/test.txt");
$writeable = 1;
} else {
$writeable = 0;
}
}
return $writeable;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment