今天无聊中练习了一下php遍历文件目录的程序,编写了以下两个程序,不过质量不是很好,轻拍~~~
1、清除php缓存文件
复制代码 代码如下:
0)
{
unlink($dir . $file);
echo delete $dir$file
;
return true;
}
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);
}
}
?>
2、遍历目录中所有文件
复制代码 代码如下:
查看目录
文件名
修改时间
文件大小(k)
http://www.bkjia.com/phpjc/327822.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/327822.htmltecharticle今天无聊中练习了一下php遍历文件目录的程序,编写了以下两个程序,不过质量不是很好,轻拍~~~ 1、清除php缓存文件 复制代码 代码如下...