Copy code The code is as follows:
/*—————————————————— * /
//– Recursively delete files and directories
//– Example: del_dir ('../cache/'); Note: the returned / is required
//– $type forces directory deletion , true yes, false no
/*———————————————————— */
function del_dir ($dir,$type=true)
{
$n=0;
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) ! == false) {
//.svn ignore svn version control information
if ( $file == '.' or $file =='..' or $file == '.svn')
{
continue;
}
if (is_file ($dir.$file))
{
unlink($dir.$file);
$n++;
}
if (is_dir ($dir.$file))
{
del_dir ($dir.$file.'/');
if ($type)
{
$n++;
rmdir($dir.$file.'/');
}
}
}
}
closedir($dh);
}
return $n;
}
http://www.bkjia.com/PHPjc/322314.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322314.htmlTechArticleCopy the code as follows: /*———————————————— — */ //– Recursively delete files and directories //– Example: del_dir ('../cache/'); Note: The returned / must be...