first commit
This commit is contained in:
26
extend/tools/Format.php
Normal file
26
extend/tools/Format.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace tools;
|
||||
|
||||
class Format
|
||||
{
|
||||
/**
|
||||
* 格式化字节数显示
|
||||
* @param integer $value
|
||||
* @return string
|
||||
*/
|
||||
public static function byte($value)
|
||||
{
|
||||
$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
|
||||
for ($i = 0; $value >= 1024 && $i < 5; $i++) {
|
||||
$value /= 1024;
|
||||
}
|
||||
return round($value, 2) . $units[$i];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user