add count size function
This commit is contained in:
parent
742cc16af0
commit
7ca9ce90fd
|
@ -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是取整函数,为了防止出现一串的小数,这里取了两位小数
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue