echo
$txt
;
?>
输出:
Hello world. Day number 123
例子
2
代码如下
:
<?php
$number
= 123;
$txt
= sprintf("%f",
$number
);
echo
$txt
;
?>
输出:
123.000000
例子
3
代码如下
:
<?php
$number
= 123;
$txt
= sprintf("With 2 decimals: %1\$.2f<br />With no decimals: %1\$u",
$number
);
echo
$txt
;
?>
输出:
代码如下
:
With 2 decimals: 123.00
With no decimals: 123
例子
4
代码如下
:
<?php
$ctype_primary
=
strtolower
('application');
$ctype_secondary
=
strtolower
('pdf');
$mimetype
= sprintf('%s/%s',
$ctype_primary
,
$ctype_secondary
);
echo
$mimetype
;