可以刪除Runtime緩存文档、或者根據自己的需求刪除指定目錄,話不多說,直接上代碼,和效果圖!
代碼示例:
function delDirAndFile($path, $delDir = true) { if (is_array($path)) { foreach ($path as $subPath) { delDirAndFile($subPath, $delDir); } } if (is_dir($path)) { $handle = opendir($path); if ($handle) { while (false !== ($item = readdir($handle))) { if ($item != "." && $item != "..") { is_dir("$path/$item") ? delDirAndFile("$path/$item", $delDir) : unlink("$path/$item"); } } closedir($handle); if ($delDir) { return rmdir($path); } } } else { if (file_exists($path)) { return unlink($path); } else { return false; } } clearstatcache(); }