azbosakov/param-string-printf 问题修复 & 功能扩展

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

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

azbosakov/param-string-printf

Composer 安装命令:

composer require azbosakov/param-string-printf

包简介

Template string with printf-style placeholders.

README 文档

README

Template string with printf-style placeholders.

When using sprintf(), the template parameters are passed as arguments. This class is sort of "delayed sprintf" - instead of variables, parameter names are passed to the constructor. There must be enough parameter names for all placeholders.

Example

use AZBosakov\ParamString\Printf;
...
$pf = new Printf('The answer is %d, the question is %s, the answer again is %d', 'ans', 'q', 'ans');
$pf = $pf->withParams(['ans'=>42, 'q'=>'"6 x 9 = ?"']);

"$pf" == "The answer is 42, the question is "6 x 9 = ?", the answer again is 42";

Methods

public function __construct(string $template, string ...$paramNames)

There must be enough params for all placeholders.

public function getTemplate() : string (ParamStringInterface)

Get the template string passed to the constructor

public function withParam(string $name, $value) : self (ParamStringInterface)

Clone the object and set the named param value.

public function getParam(string $name) (ParamStringInterface)

Get a parameter by name

public function withParams(array $params) : self (ParamStringInterface)

Clone the object and set multiple params at once.

public function getParams() : array (ParamStringInterface)

Get a snapshot of the parameters

public function __toString() : string (ParamStringInterface)

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固