jalet/util-sprintf

PHP的sprintf函数,支持命名参数和类型转换。

此包的官方仓库似乎已不存在,因此该包已被冻结。

dev-master 2013-04-24 09:37 UTC

This package is not auto-updated.

Last update: 2020-01-24 15:14:41 UTC


README

PHP的sprintf函数,支持命名参数和类型转换。

use Jalet\Util\Sprintf;

echo Sprintf::f("I am %age:int% years old.", array('age' => '25y'));
// I am 25 years old.

echo Sprintf::f("Oh my god, it's %val:bool:str%.", array('val' => 1)); 
// Oh my god, it's true.

echo Sprintf::f("My cat is %color%.", array('color' => 'brown'));
// My cat is brown.


echo Sprintf::f("INSERT INTO table (username, active) VALUES ('john.doe', %active:bool%);", array('active' => false));
// INSERT INTO table (username, active) VALUES ('john.doe', 0);

Build Status