Copy code The 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 for counting the number of directories
*/
$filesize['file'] = 0;
if(@rmdir($fpath) === true) {
echo "{$filepath}............Delete successfully
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 successfully
n";
} else {
echo "{$filepath}...{$fsize}K............Delete failed
}
}
}
return $filesize;
}
/*
* function getArrSum(array &$arr) array sum
* array &$arr processed array
*/
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('Saves you: %.3fM Space', $size/(1024*1024));
?>
The above introduces how to clear the computer cache, delete the php folder, and clear the php cache program, including how to clear the computer cache. I hope it will be helpful to friends who are interested in PHP tutorials.