【发布时间】:2017-03-06 06:50:43
【问题描述】:
这段代码有什么作用? 我主要看不懂while循环! 主要看不懂$total--
function getNiceFileSize($file, $digits = 2)
{
if(is_file($file)){
$filePath = $file;
if(!realpath($filePath)){
$filePath = $_SERVER["DOCUMENT_ROOT"] . $filePath;
}
$fileSize = filesize($filePath);
$sizes = array("TB", "GB", "MB", "KB", "B");
$total = count($sizes);
while ($total-- && $fileSize > 1024){
$fileSize /= 1024;
}
return round($fileSize, $digits). " " . $sizes[$total];
}
return false;
}
【问题讨论】:
标签: php file-manager