add count size function

This commit is contained in:
Jianxuan Li 2015-04-29 15:18:23 +08:00
parent 742cc16af0
commit 7ca9ce90fd
1 changed files with 10 additions and 0 deletions

View File

@ -114,5 +114,15 @@ class Tools {
} }
return $protocol."://".$_SERVER['SERVER_NAME']; return $protocol."://".$_SERVER['SERVER_NAME'];
} }
function count_size($bit)
{
$type = array('Bytes','KB','MB','GB','TB');
for($i = 0; $bit >= 1024; $i++)//单位每增大1024则单位数组向后移动一位表示相应的单位
{
$bit/=1024;
}
return (floor($bit*100)/100).$type[$i];//floor是取整函数为了防止出现一串的小数这里取了两位小数
}
} }