日期:2010-11-04  浏览次数:20545 次


<?php
    /**
     * c_function::dir_delete()
     * 删除目录
     * @param $file 目录名(不带/)
     * @return
     */
     function dir_delete($file)
     {
        if(file_exists($file))
        {
            if(is_dir($file))
            {
                $handle =opendir($file);
                while(false!==($filename=readdir($handle)))
                {
                    if($filename!="."&&$filename!="..")$this->dir_delete($file."/".$filename);
                }
                closedir($handle);
                rmdir($file);
                return true;
            }
            else
            {
                unlink($file);
            }
        }
    }
?>