Copy CodeThe code is as follows:
Header (' Content-type:text/html;charset=utf-8 ');
function Delfile ($fpath) {
$filesize = Array ();
$filepath = Iconv (' gb2312 ', ' utf-8 ', $fpath);
if (Is_dir ($fpath)) {
if ($dh = Opendir ($fpath)) {
while (($file = Readdir ($DH))!== false) {
if ($file! = '. ' && $file! = ' ... ') {
$filesize [] = Delfile ($fpath. ' /'. $file);
}
}
Closedir ($DH);
}
/*
* Convenient Statistics Directory number
*/
$filesize [' file '] = 0;
if (@rmdir ($fpath) = = = True) {
echo "{$filepath} ..... ....." Delete Succeeded
\ n ";
} else {
echo "{$filepath} ..... ....." Delete failed
\ n ";
}
} else {
if (Is_file ($fpath)) {
$filesize [] = $fsize = FileSize ($fpath);
if (@unlink ($fpath) = = = True) {
echo "{$filepath} ... {$fsize} K................ Delete Succeeded
\ n ";
} else {
echo "{$filepath} ... {$fsize} K................ Delete failed
\ n ";
}
}
}
return $filesize;
}
/*
* Function Getarrsum (array & $arr) Arrays summation
* Array & $arr processed arrays
*/
Function Getarrsum (& $arr) {
if (Is_array ($arr)) {
foreach ($arr as & $value) {
$value = Getarrsum ($value);
}
Return Array_sum ($arr);
} else {
return $arr;
}
}
$fpath = ' d:/test ';
$filesize = Delfile ($fpath);
$size = Getarrsum ($filesize);
printf (' Save for You:%.3fm space ', $size/(1024*1024));
?>
Just build a test folder under D, and then you can test it with a little something inside.
The above describes how to clear the Computer cache php folder Delete, PHP clear the cache program, including how to clear the computer cache content, I hope that the PHP tutorial interested friends helpful.