PHP学院的中学生 2019-05-22 09:41:44 1764次浏览 1条回复 0 0 0
<?php
/**
 * 删除文件夹内的文件
 *
 * @param $dir
 * @return bool
 */
public static function delDirFile($dir)
{
    if (! file_exists($dir)) {
        return true;
    }
    if (is_dir($dir)) {
        $dh = opendir($dir);
        while ($file = readdir($dh)) {
            if ($file != "." && $file != "..") {
                $fullpath = $dir . "/" . $file;
                if (! is_dir($fullpath)) {
                    unlink($fullpath);
                }
            }
        }
        closedir($dh);
    }
}
您需要登录后才可以回复。登录 | 立即注册