Fork me on GitHub
代码改变世界

删除文件夹及文件夹内的文件

2013-05-27 16:27  freefei  阅读(273)  评论(0编辑  收藏  举报
[php] //删除文件夹 function deldir($dir) { //先删除目录下的文件: $dh=opendir($dir); while ($file=readdir($dh)) { if($file!="." && $file!="..") { $fullpath=$dir."/".$file; if(!is_dir($fullpath)) { unlink($fullpath); } else { deldir($fullpath); } } } closedir($dh); //删除当前文件夹: if(rmdir($dir)) { return true; } else { return false; } } [/php] thinkphp 使用模块 案例 function cache_index(){ $dele=deldir('Cache/data'); if($dele){ $this->success("更新主页缓存成功!"); } }
@ https://github.com/ranmufei

守望者舆情监控

守望者舆情监控系统