- sprintf — 返回格式化的字符串
// 说明:sprintf ( string $format [, mixed $... ] ) : string
// string - s
// integer - d, u, c, o, x, X, b
// double - g, G, e, E, f, F
$num = 5;
$location = 'tree';
$format = 'There are %d monkeys in the %s';
echo sprintf($format, $num, $location); // 输出:"There are 5 monkeys in the tree"
// 指定顺序
$format = 'The %2$s contains %1$d monkeys';
echo sprintf($format, $num, $location);// 输出:"The tree contains 5 monkeys"