如何用php創(chuàng)建與刪除多級(jí)目錄函數(shù)
來源:程序員人生 發(fā)布時(shí)間:2013-11-03 18:52:04 閱讀次數(shù):2413次
-
- 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);
- }
- }
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對(duì)您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)