码迷,mamicode.com
首页 > Web开发 > 详细

php的%s

时间:2018-05-18 14:15:25      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:csharp   txt   变量   sprintf   settings   cal   ash   函数   符号   

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

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

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

输出:
Hello world.  number 123

 

php的%s

标签:csharp   txt   变量   sprintf   settings   cal   ash   函数   符号   

原文地址:https://www.cnblogs.com/aten/p/9055337.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!