案例-遍历目录,输出所有文件文件夹(递归)
遍历目录,输出所有文件文件夹(递归)
";
$str .= "".$filename." ";
$str .= "".getfilesize(filesize($file_path))." ";
$str .= "".(filetype($file_path) == 'dir' ? '目录':'文件') ." ";
$str .= "".(date('Y-m-d H:i:s' , filectime($file_path))) ." ";
$str .= "".(date('Y-m-d H:i:s' , filemtime($file_path))) ." ";
$str .= "".(is_readable($file_path) == 1 ?'YES' : 'NO') ." ";
$str .= "";
}
closedir($res);
return $str;
}
echo "| 文件名 | "; echo "文件大小 | "; echo "类型 | "; echo "创建时间 | "; echo "修改时间 | "; echo "是否可读 | "; echo "
|---|
遍历目录,输出所有文件(递归)
//加一个输出判断is_file()
if(is_file($file_path)){
$color = $num % 2 == 0 ? '#abcdef': '#fff';
$str .= "";
$str .= "".$filename." ";
$str .= "".getfilesize(filesize($file_path))." ";
$str .= "".(filetype($file_path) == 'dir' ? '目录':'文件') ." ";
$str .= "".(date('Y-m-d H:i:s' , filectime($file_path))) ." ";
$str .= "".(date('Y-m-d H:i:s' , filemtime($file_path))) ." ";
$str .= "".(is_readable($file_path) == 1 ?'YES' : 'NO') ." ";
$str .= " ";
} 本站文章如未注明出处均为原创,转载请注明出处,如有侵权请邮件联系站长。