"Go from e-mentor Network " Here is an example: rounding retains two digits after the decimal point
650) this.width=650; "src=" Http://183.61.143.148/group1/M00/01/FA/tz2PlFQH_1_QKdbuAAAfVXuKLV4952.png "/>
explain the meaning of the following%0.2f:
% represents the starting character
0 indicates that the empty space is filled with 0
2 means that the decimal point must be two bits
Span style= "Line-height:2;font-size:16px;font-family:simsun;" > F to convert to floating point number
Convert characters
% printed percent symbol, not converted.
b integer turns into binary.
The c integer is converted to the corresponding ASCII character.
D integers are turned into 10.
The F-Times precision number is converted to floating point numbers.
o integers are turned into octal.
The s integer is converted into a string.
The x integer is converted to lowercase 16 rounding.
X integers are converted to uppercase 16 rounding.
the difference between printf and sprintf
1. printf function:
int printf (string format [, mixed args [, mixed ...])
produces output according to format, which are described in the documentation for SPRINTF ().
Returns The length of the outputted string.
the text is formatted for later output, such as:
650) this.width=650; "src=" Http://183.61.143.148/group1/M00/01/FA/tz2PlFQH_3iAyTr3AAAL4QtsyQA162.png "/>
2. sprintf function:
string sprintf (string format [, mixed args [, mixed ...])
Returns A string produced according to the formatting string format.
similar to printf, but does not print, but returns formatted text, the rest is the same as printf.
3. Print function:
is a function that returns a value that can have only one parameter.
int Print (string arg)
Outputs Arg. Returns 1, always.
more Programming Language Tutorials Knowledge Please login e mentor net.
This article is from the "Add Language" blog, please make sure to keep this source http://yuguotianqing.blog.51cto.com/9292883/1549396
sprintf and printf two functions in PHP usage tips