如何使此脚本删除文件夹中的文件夹

时间:2017-08-01 18:17:44

标签: php

如何让这个脚本删除文件夹中的文件夹,生产文件夹中有一个名为twig的文件夹,但无法删除

    <?php

// Deletes everything but index.htm and .htaccess from the phpBB cache directory

$cachedir = "cache/production";

    $dir = opendir($cachedir);    

// Delete everything but index.htm and .htaccess

    while( $file = readdir( $dir ) ) {
       if ($file == "." or $file == ".." or $file == "index.htm" or $file == ".htaccess") {
          continue;
       }
       echo "Deleting $cachedir/$file ... ";
       if (unlink("$cachedir/$file")) {
          echo "Done.<BR>";
       } else {
          echo "Not done.<BR>";
       }
    }

?>

0 个答案:

没有答案