PHP技巧:PHP中幾種刪除目錄的三種方法_PHP教程
推薦:PHP技巧:PHP腳本編程中的文件系統(tǒng)函數(shù)庫basename: 返回不含路徑的文件字符串。 chgrp: 改變文件所屬的群組。 chmod: 改變文件的屬性。 chown: 改變文件的擁有者。 clearstatcache: 清除文件狀態(tài)快取。 copy: 復(fù)制文件。 d
1、遞規(guī)法:
| 以下為引用的內(nèi)容: deleteDir($dir) { if (rmdir($dir)==false && is_dir($dir)) { if ($dp = opendir($dir)) { while (($file=readdir($dp)) != false) { if (is_dir($file) && $file!='.' && $file!='..') { deleteDir($file); } else { unlink($file); } } closedir($dp); } else { exit('Not permission'); } } } |
2、系統(tǒng)調(diào)用法
| 以下為引用的內(nèi)容: function del_dir($dir) { if(strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { $str = "rmdir /s/q " . $dir; } else { $str = "rm -Rf " . $dir; } } |
3、循環(huán)法
| 以下為引用的內(nèi)容: function deltree($pathdir) |
分享:PHP技巧:PHP腳本中關(guān)于拼寫檢查函數(shù)庫aspell_new : 載入一個新的字典。 aspell_check : 檢查一個單字。 aspell_check-raw : 檢查一個單字,即使拼錯也不改變或修正。 aspell_suggest : 檢查一個單字,并提供拼寫建議。
- PHPNOW安裝Memcached擴(kuò)展方法詳解
- php記錄頁面代碼執(zhí)行時間
- PHP中獎概率的抽獎算法程序代碼
- apache設(shè)置靜態(tài)文件緩存方法介紹
- php對圖像的各種處理函數(shù)代碼小結(jié)
- PHP 關(guān)于訪問控制的和運(yùn)算符優(yōu)先級介紹
- 關(guān)于PHP語言構(gòu)造器介紹
- php/js獲取客戶端mac地址的實現(xiàn)代碼
- php5.5新數(shù)組函數(shù)array_column使用
- PHP preg_match的匹配多國語言的技巧
- php 中序列化和json使用介紹
- php采集文章中的圖片獲取替換到本地
- 相關(guān)鏈接:
- 教程說明:
PHP教程-PHP技巧:PHP中幾種刪除目錄的三種方法
。