stk2k/string-format
Composer 安装命令:
composer require stk2k/string-format
包简介
String formatter(C# String.Format/sprintf)
关键字:
README 文档
README
Description
String formatter(C# String.Format/sprintf)
Feature
- Supports PHP sprintf formatter and C# String.Format formatter
- You can implement your own formatter(StringFormatterInterface)
- Implemented as a static method in trait
Usage
PHP sprintf formatter
use stk2k\string\format\test\classes\MyStringClass; use stk2k\string\format\formatter\PhpSprintfStringFormatter; MyStringClass::setStringFormatter(new PhpSprintfStringFormatter()); // string echo MyStringClass::format('Hello, %s!', 'David'); // Hello, David! // integer echo MyStringClass::format('Come here after %d days', 3); // Come here after 3 days echo MyStringClass::format('%04d-%02d-%02d', 2021, 6, 10); // 2021-06-10 // float echo MyStringClass::format('%.03f', 3.1414926535); // 3.141 // exponent echo MyStringClass::format('%.3e', 362525200); // 3.625e+8 echo MyStringClass::format('%.3E', 362525200); // 3.625E+8
C# String.Format formatter
use stk2k\string\format\test\classes\MyStringClass; use stk2k\string\format\formatter\PhpSprintfStringFormatter; // string echo MyStringClass::format('Hello, {0}!', 'David'); // Hello, David! // integer echo MyStringClass::format('Come here after {0:d} days', 3); // Come here after 3 days echo MyStringClass::format('{0:d4}-{1:d2}-{2:d2}', 2021, 6, 10); // 2021-06-10 // float echo MyStringClass::format('{0:F3}', 3.1414926535); // 3.141 // exponent echo MyStringClass::format('{0:e3}', 362525200); // 3.625e+8 echo MyStringClass::format('{0:E3}', 362525200); // 3.625E+8 // number echo MyStringClass::format('{0:n}', 123456.789); // 123,456.79 echo MyStringClass::format('{0:n3}', 123456.789); // 123,456.789 echo MyStringClass::format('{0:n4}', 123456.789); // 123,456.7890 // percentage echo MyStringClass::format('Ratio: {0:P}', 0.18); // Ratio: 18.00% echo MyStringClass::format('Ratio: {0:P3}', 0.18); // Ratio: 18.000% echo MyStringClass::format('Ratio: {0:P4}', 0.18); // Ratio: 18.0000% // hexadecimal number echo MyStringClass::format('{0:X}', 10); // A echo MyStringClass::format('{0:X3}', 10); // 00A
Requirement
PHP 7.2 or later
Installing stk2k/string-format
The recommended way to install stk2k/string-format is through Composer.
composer require stk2k/string-format
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
License
This library is licensed under the MIT license.
Author
Disclaimer
This software is no warranty.
We are not responsible for any results caused by the use of this software.
Please use the responsibility of the your self.
stk2k/string-format 适用场景与选型建议
stk2k/string-format 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 402 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 06 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「formatter」 「format」 「string」 「C sharp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 stk2k/string-format 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 stk2k/string-format 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 stk2k/string-format 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Provides a simple decimal/roman number converter
Softonic OpenApi validation formats extension
Tools to convert between .NET and PHP date formats
Yii2 phone formatter and validator.
Adds the EDTF data type to Wikibase
Custom laravel monolog logger for datadog logs management, both api and agent ways
统计信息
- 总下载量: 402
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-06-09