//PHP删除目录和目录内所有的下级目录、文件代码
function delDir( $dirName='' ){
if ( $handle = opendir( "$dirName" ) ) {
while ( false !== ( $item = readdir( $handle ) ) ) {
if ( $item != "." && $item != ".." ) {
if ( is_dir( "$dirName/$item" ) ) {
$this->delDir( "$dirName/$item" );
} else {
unlink( "$dirName/$item" );
}
}
}
closedir( $handle );
}
}
delDir('目录');
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn