php sprintf () function to write a string format variable.

Source: https://blog.csdn.net/zxh1220/article/details/79709207

HP sprintf () function parameters used

 

 

printf - formatted string

sprintf () function to write a string format variable.

%% - Returns the percent sign
% b - binary
% c - character ASCII value in accordance with the
% d - signed decimal number
% e - renewable counting (eg. 3 + 1.5E)
% U - unsigned decimal number
% f - float (local Aware Settings)
% F. - a float (Not local Aware Settings)
% O - octal
% s - string
% x - hexadecimal (lowercase letters)
% X-- hexadecimal number (uppercase letter)

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

 


% S is to replace $ str,% d is replaced with the $ number
output:
the Hello World Number 123.

Guess you like

Origin www.cnblogs.com/laijinquan/p/11697205.html