zoukankan      html  css  js  c++  java
  • PHP 删除目录及目录下文件

    <?php

    function del_dir ($dir,$type=true)
    {
        $n=0;
        if (is_dir($dir)) {
            if ($dh = opendir($dir)) {
                while (($file = readdir($dh)) !== false) {
                    if ( $file == '.' or $file =='..')
                    {
                        continue;
                    }
                    if (is_file ($dir.$file))
                    {
                        unlink($dir.$file);
                        $n++;
                    }
                    if (is_dir ($dir.$file))
                    {
                        del_dir ($dir.$file.'/');
                        if ($type)
                        {
                            $n++;
                            rmdir($dir.$file.'/');
                        }
                    }
                }
            }
            closedir($dh);
        }
        return $n;
    }

    ?>

  • 相关阅读:
    C#设计模式-原型模式
    C#设计模式-建造者模式
    c#设计模式-组合模式
    c#设计模式-适配器模式
    c#设计模式-命令模式
    c#设计模式-观察者模式
    c#设计模式-工厂方法
    C#设计模式-简单工厂
    C#设计模式-工厂模式
    C#设计模式-单例模式
  • 原文地址:https://www.cnblogs.com/laowenBlog/p/6067945.html
Copyright © 2011-2022 走看看