| // +------------------------------------------------+ 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]; } }