删除文件夹下所有文件

发表于

    //删除文件夹下所有文件
    public function delFiles($dir = './Public/Cache/')
    {
        $dh = opendir($dir);
        while ($file = readdir($dh)) {
            if ($file != "." && $file != "..") {
                $fullpath = $dir . "/" . $file;
                if (!is_dir($fullpath)) {
                    unlink($fullpath);
                } else {
                    delFiles($fullpath);
                }
            }
        }
        closedir($dh);
    }
    //调用
    public function del()
    {
        $this->delFiles('./111111/');
    }

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注