<?php
function read_dir($dir,$file)
{
$a =strpos($file,".php");
if($a>0)
{
unlink($dir . $file);
echo "delete $dir$file <br>";
return true;
}
//by www.jb200.com
if(strpos($file,".") === 0 || strpos($file,".") !== false ) return true;
if(strpos($file,".") === false || strpos($dir,"/") === false)
{
$dir = $dir . $file . "/";
if(!is_dir($dir)) return false;
$dh = opendir($dir);
while(($file = readdir($dh)) != false)
{
read_dir($dir,$file); //
递归调用
}
}
}
function clear_caches()
{
$dir = "./temp/"; //要清除的PHP缓存文件目录
if(!is_dir($dir)) die("It is not a dir");
$dh = opendir($dir);
while(($file = readdir($dh) )!=false)
{
//var_dump($file);
read_dir($dir,$file);
}
}
?>