php to take the integer function commonly used in four ways:
1. Direct rounding, discard decimals, keep integers: intval ();
2. Rounded rounding: round ();
3. Take the whole up, there are decimals plus 1:ceil ();
4. Take the whole down: floor ().
One, intval-to the variable to the integer form
Intval is automatically converted to 0 if it is a character type.
Intval (3.14159); 3
intval (3.64159); 3
intval (' Ruesin ');//0
Second, rounded: round ()
The parameter 1 is rounded according to the specified precision of parameter 2. Parameter 2 can be a negative number or 0 (the default value).
Round (3.14159); 3
round (3.64159); 4
round (3.64159, 0); 4
Round (3.64159, 2); 3.64
Round (5.64159, 3); 3.642
Round (364159,-2); 364200
Third, to take the whole up, with a decimal number plus 1:ceil ()
Returns the next integer that is not less than value, or the value if there is a decimal part.
This method is often used when we write page classes to calculate the number of pages.
Ceil (3.14159); 4
ceil (3.64159); 4
Four, downward rounding: Floor ()
Returns the next integer not more than value, rounding out the decimal part of value.
Floor (3.14159); 3
floor (3.64159); 3
Reprint please indicate the source: http://blog.csdn.net/churk2012/article/details/51424588