做页封装创建目录。读取目录并包含目录大小的方法

Original 2019-03-21 11:44:01 301
abstract: //读取文件信息 function getfileinfo($finame){ $arr[]=''; $tiem = opendir($finame); while ($src = readdir($tiem)) { if ($src!="." && $src!=

//读取文件信息

function getfileinfo($finame){

$arr[]='';

$tiem = opendir($finame);

while ($src = readdir($tiem)) {

if ($src!="." && $src!= "..") {

if (is_file($finame."/".$src)) {

$arr['file'][] = $src;

}

if (is_dir($finame."/".$src)) {

$arr['dir'][] = $src;

}

}

}

closedir($tiem);

return $arr;

}

var_dump(getfileinfo('bbbb'));

echo "


";

//获取目录文件大小

function getinfo($path){

$sum = 0;

global $sum;

$dir = opendir($path);

while ($time = readdir($dir)) {

if ($time!="." && $time!="..") {

if (is_file($path."/".$time)) {

$sum += filesize($path."/".$time);

}

if (is_dir($path."/".$time)) {

$fun = __FUNCTION__;

$fun($path."/".$time);

}

}

}

closedir($dir);

return $sum;

}

echo getinfo('bbbb');

function mkdirll($drname){

if (file_exists($drname)) {

return '目录已经存在';

}

if (mkdir($drname,0777,true)) {

return '目录创建成功';

}

return '目录创建失败';

}


Correcting teacher:天蓬老师Correction time:2019-03-21 13:07:07
Teacher's summary:php操作文件的功能, 并不是很强大, 但是可以通过标准库提供的工具来操作

Release Notes

Popular Entries