1
0
Files
helper/extend/tools/Format.php
2020-08-06 14:58:51 +08:00

27 lines
820 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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];
}
}