php中通過DirectoryIterator刪除整個目錄的方法
來源:易賢網(wǎng) 閱讀:1115 次 日期:2015-03-16 10:30:14
溫馨提示:易賢網(wǎng)小編為您整理了“php中通過DirectoryIterator刪除整個目錄的方法”,方便廣大網(wǎng)友查閱!

這篇文章主要介紹了php中通過DirectoryIterator刪除整個目錄的方法,實例分析了php通過DirectoryIterator類操作目錄的技巧,具有一定參考借鑒價值,需要的朋友可以參考下

本文實例講述了php中通過DirectoryIterator刪除整個目錄的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:

<?php

function cleanup_directory($dir) {

foreach (new DirectoryIterator($dir) as $file) {

if ($file->isDir()) {

if (! $file->isDot()) {

cleanup_directory($file->getPathname());

}

} else {

unlink($file->getPathname());

}

}

rmdir($dir);

}

?>

希望本文所述對大家的php程序設計有所幫助。

更多信息請查看IT技術(shù)專欄

更多信息請查看網(wǎng)絡編程
易賢網(wǎng)手機網(wǎng)站地址:php中通過DirectoryIterator刪除整個目錄的方法
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權(quán)所有:易賢網(wǎng)