您的位置:首页 > 其它

封装函数

2018-03-30 13:14 232 查看
1.删除文件夹
function dir_del($dir)
{
    if (!is_dir($dir)) {
        return NULL;
    }
    $handle = opendir($dir);
    while (($file = readdir($handle)) !== false) {
        if ($file != '.' && $file != '..') {
            $fullpath = $dir . '/' . $file;
            if (!is_dir($fullpath)) {
                @unlink($fullpath);
            } else {
                dir_del($fullpath);
            }
        }
    }
    closedir($handle);
    if (rmdir($dir)) {
        return true;
    } else {
        return false;
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  函数封装