数字辅助函数¶
数字辅助函数文件包含了用于处理数字的一些函数。
可用函数¶
该辅助函数有下列可用函数:
- byte_format($num[, $precision = 1])¶
- 参数: - $num (mixed) -- Number of bytes
- $precision (int) -- Floating point precision
 - 返回: - Formatted data size string - 返回类型: - string - 根据数值大小以字节的形式格式化,并添加适合的缩写单位。 例如: - echo byte_format(456); // Returns 456 Bytes echo byte_format(4567); // Returns 4.5 KB echo byte_format(45678); // Returns 44.6 KB echo byte_format(456789); // Returns 447.8 KB echo byte_format(3456789); // Returns 3.3 MB echo byte_format(12345678912345); // Returns 1.8 GB echo byte_format(123456789123456789); // Returns 11,228.3 TB - 可选的第二个参数允许你设置结果的精度: - echo byte_format(45678, 2); // Returns 44.61 KB - 注解 - 这个函数生成的缩写单位可以在 language/<your_lang>/number_lang.php 语言文件中找到。