如何用php創建與刪除多級目錄函數
來源:程序員人生 發布時間:2013-11-03 18:52:04 閱讀次數:2418次
-
- function deldir($dir)
- {
- $dh=opendir($dir);
- while ($file=readdir($dh))
- {
- if($file!="." && $file!="..")
- {
- $fullpath=$dir."/".$file;
- if(!is_dir($fullpath))
- {
- unlink($fullpath);
- }
- else
- {
- $this -> deldir($fullpath);
- }
- }
- }
- closedir($dh);
- if(rmdir($dir))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
- function createFolder($path)
- {
- if (!file_exists($path)){
- createFolder(dirname($path));
- mkdir($path, 0777);
- }
- }
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈