In PHP development we may encounter a line of words with double quotation marks to make that line of words into a string, and if there are other characters in a line of words, and so on, we use double quotation marks or single quotation marks are very prone to errors, then we are today to talk about how the PHP character formatting it!
Fortunately, our PHP function can be directly used with the PHP sprintf () function
printf// Output formatted string sprintf ()//function writes a formatted string to a variable.
The parameters used by the PHP sprintf () function are as follows:
%//return percent symbol%B//binary number%c//character%d per ASCII value//Signed decimal number%e//sustainable counting method (e.g. 1.5e+3)%u//unsigned decimal number%F//floating point (Local settings Aware)%F//floating point (not local Settings Aware)%o//Eight decimal number%s//string%x//16 decimal (lowercase)%x//16 decimal number (capital letter)
Code Case :
<?php$str = "Hello"; $number = 123; $txt = sprintf ("%s World"). Number%d ", $STR, $number); Echo $txt;? >
Code Results :
Hello World. Number 123
Very easy to understand, we look at more, and then directly write some, you will find really convenient Oh!
Related recommendations:
PHP Format Code Related 10 Tutorial Summary