<?php
$dirname = "test1";
//mkdir($dirname);
//遍历一层目录
function listdir($dirname) {
$ds = opendir($dirname);
while($file = readdir($ds)) {
$path = $dirname.'/'.$file;
if(is_dir($file)) {
echo "dir:".$file."<br>";
if($file != "." && $file != "..") {
listdir($file);
}
}
else {
echo "file:".$file . "<br>";
}
}
}
function totdir($dirname) { //对listdir稍加修改
static $tot = 0;
$ds = opendir($dirname);
while($file = readdir($ds)) {
$path = $dirname.'/'.$file;
if(is_dir($file)) {
//echo "dir:".$file."<br>";
if($file != "." && $file != "..") {
$tot += totdir($file);
}
}
else {
//echo "file:".$file . "<br>";
$tot += filesize($path);
}
}
//返回总计
return $tot;
}
listdir($dirname);
echo totdir($dirname)." bytes";
?>
如对本文有疑问,
点击进行留言回复!!
相关文章:
-
-
-
-
-
-
基于口令的密码
1. 基于口令的密码我们需要了解两个主要过程:1.加解密过程;2.获取加密密钥值。我们可以看到的是加解密过程就是...
[阅读全文]
-
-
浅谈堡垒机的由来
堡垒机现身企业内控运维安全"终结者"。堡垒机,听起来就是一个够酷的名字,有用户笑言,听着名儿就觉着安全,就像大块...
[阅读全文]
-
-
密码散列算法
密码散列算法是password扩展,他是PHP核心的一部分,不需要单独安装这个库是专门对密码做hash运算与校验...
[阅读全文]
-
网友评论