jderusse/format
Composer 安装命令:
composer require jderusse/format
包简介
Simple function to format strings
README 文档
README
# Format
Format provide the ability to do variable substitutions.
## Installation
composer require jderusse/format
Usage
format('Hello {who}', ['who' => 'World']);
Usecase
throw new \Exception(format('Fail to load resource "{resource}".', ['resource' => $fileName]);
$this->addFlash(format('Project "{name}" succesfully created.', ['name' => $project->getName()]);
Why?
Because I'm not happy with language alternatives.
- echo 'Should I use "'."'".'" or "'.'"'.'"'; + echo format('Should I use "{single}" or "{double}"', ['single'=> "'", 'double' => '"']);
- sprintf('%s likes when %s repeat the same things', $user, $user'); + format('{user} like when {user} repeat the same things', ['user'=> $user]);
- sprintf('%s%s%s', $scheme, $host, $path'); + format('{scheme}{host}{path}', ['scheme' => $scheme, 'host' => $host, 'path' => $path]);
- echo "Hello {$this->getUser()->getusername()}. Welcome in {$this->getProject()->getName()}": + echo format('Hello {user}. Welcome in {project}', ['user' => $this->getUser()->getusername(), 'project' => $this->getProject()->getName()]):
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-12-16