ramazancetinkaya/byte-formatter

一个用于将字节格式化为可读格式以及反之的PHP库。

1.0.0 2023-12-29 14:02 UTC

This package is auto-updated.

Last update: 2024-09-29 22:43:16 UTC


README

License Version PHP GitHub stars

一个可以将字节格式化为可读格式以及反之的PHP库。

报告错误 · 创建新Pull Request

概述

此库提供将字节转换为可读格式以及反之的功能。它允许自定义格式化选项并支持对无效输入的错误处理。

安装

您可以通过 Composer 安装此库。运行以下命令

composer require ramazancetinkaya/byte-formatter

用法

<?php

require 'vendor/autoload.php'; // Composer autoload file

use ramazancetinkaya\ByteFormatter;

// Create an instance of ByteFormatter
$formatter = new ByteFormatter();

// Format bytes
echo $formatter->format(2048); // Output: 2 KB

// Convert from human-readable size to bytes
echo $formatter->convertToBytes('2 KB'); // Output: 2048

贡献

欢迎贡献!请fork仓库并创建pull request。

许可证

本项目采用MIT许可证。有关更多详细信息,请参阅 LICENSE 文件。