php删除文件夹php
php删除文件夹...
<?php
function delete_file($path){
if(is_dir($path)){
if($res = opendir($path)){
while($file=readdir($res)){
if($file != '.' && $file != '..'){
if(is_file($path.'/'.$file)){
unlink($path.'/'.$file);
}else if(is_dir($path.'/'.$file)){
delete_file($path.'/'.$file);
}
}
}
closedir($res);
rmdir($path);
}
}else if(is_file($path)){
unlink($path);
}
}
相关函数:
unlink() 函数删除文件。
rmdir() 函数删除空的目录。
function delete_file($path){
if(is_dir($path)){
if($res = opendir($path)){
while($file=readdir($res)){
if($file != '.' && $file != '..'){
if(is_file($path.'/'.$file)){
unlink($path.'/'.$file);
}else if(is_dir($path.'/'.$file)){
delete_file($path.'/'.$file);
}
}
}
closedir($res);
rmdir($path);
}
}else if(is_file($path)){
unlink($path);
}
}
相关函数:
unlink() 函数删除文件。
rmdir() 函数删除空的目录。
上一篇:php将数组插入数据库
最新评论
热门推荐
我要评论