Home Article PHP中,%s与%d是什么意思


Release time:2018-12-08 16:03:24 Author:Aoe Wide Reading volume:315
PHP sprintf() 函数用到的参数



printf — 输出格式化字符串

sprintf() 函数把格式化的字符串写入一个变量中。

%% - 返回百分比符号
%b - 二进制数
%c - 依照 ASCII 值的字符
%d - 带符号十进制数
%e - 可续计数法(比如 1.5e+3)
%u - 无符号十进制数
%f - 浮点数(local settings aware)
%F - 浮点数(not local settings aware)
%o - 八进制数
%s - 字符串
%x - 十六进制数(小写字母)
%X - 十六进制数(大写字母)

$str = "Hello";
$number = 123;
$txt = sprintf("%s world.  number %d",$str,$number);
echo $txt;


Hello world.  number 123

I want to comment

User comments

Comment time:2019-03-28 20:12:29


Leave a message
User login
You have not written any reviews yet!
You have commented!
Can only praise once!
You have a collection!