删除文件夹

mac2022-06-30  20

删除文件夹


 

示例:

<?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() 函数删除空的目录。

 

转载于:https://www.cnblogs.com/gyfluck/p/10621240.html

相关资源:快速删除文件夹中的文件
最新回复(0)