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;
    }

    ?>

  • 相关阅读:
    CSS(八) 常见的居中定位
    VUE常用的标签属性和指令
    ES6面向对象
    ES6解构赋值
    jvarScript的多个参数
    ES6的箭头函数
    Light OJ 1125 Divisible Group Sums
    Light OJ 1168 Wishing Snake
    Light OJ 1044 Palindrome Partitioning
    hdu 3967 Zero's Number
  • 原文地址:https://www.cnblogs.com/laowenBlog/p/6067945.html
Copyright © 2011-2022 走看看