simbiat/cute-bytes 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

simbiat/cute-bytes

最新稳定版本:4.0.1+20250417

Composer 安装命令:

composer require simbiat/cute-bytes

包简介

Class to present bytes in readable format

README 文档

README

Class to present bytes (numeric value) as a human-readable string. There are several reasons you would want to use this library and not the common one-liner (or 3-liner) approach:

  • No missing postfixes in case of too big or too small values.
  • No superfluous trailing zeros.
  • Follows SI format by default (power of 10 can be switched to power of 2, if so desired).
  • Shows thousands by default (adjustable) for extra readability in some cases.

How to use

Easy:

echo \Simbiat\CuteBytes::bytes(1234567890);

will output 1,234.57 MB

You can change decimal and thousands delimiters or change the number of decimals (precision)

echo \Simbiat\CuteBytes::bytes(1234567890, decimals: 3, dec_point: ',', thousands_sep: '.');

to get 1.234,568 MB

If you want to drop thousands, set the default number of numbers shown

echo \Simbiat\CuteBytes::bytes(1234567890, numbers: 0);

to get 1.23 GB

If you want to use "classic" logic, that is binary, power of 2, use

echo \Simbiat\CuteBytes::bytes(1234567890, 1024);

to get 1,177.38 MB (note some additional loss of precision)

统计信息

  • 总下载量: 249
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 2

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: AGPL-3.0-or-later
  • 更新时间: 2018-12-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固