php 递归删除目录下的文件
<?php
// $dir:要删除的文件的目录
function recursiveDelete($dir)
{
// 打开指定目录
if ($handle = @opendir($dir))
{
while (($file = readdir($handle)) !== false)
{
if (($file == ".") || ($file == ".."))
{
continue;
}
if (is_dir($dir . '/' . $file))
{
// 递归
recursiveDelete($dir . '/' . $file);
}
else
{
unlink($dir . '/' . $file); // 删除文件
}
}
@closedir($handle);
rmdir ($dir);
}
}
相关推荐
大地飞鸿 2020-11-12
steeven 2020-11-10
Tips 2020-10-14
nongfusanquan0 2020-08-18
yedaoxiaodi 2020-07-26
夜晚00 2020-07-03
hanyujianke 2020-06-28
xhao 2020-06-28
清溪算法君老号 2020-06-27
pengkingli 2020-06-25
yishujixiaoxiao 2020-06-25
Masimaro 2020-06-21
清溪算法 2020-06-21
oXiaoChong 2020-06-20
RememberMePlease 2020-06-17
chaigang 2020-06-13