1. Using forced type conversions
First, PHP supports data types such as the following:
1. Integer (整数)2. Float (浮点数)3. String (字符串)4. Boolean (布尔值)5. Array (数组)6. Object (对象)
There are also two special types: null (empty), resource (Resource).
Note:
1. A variable that is not assigned, has been reset, or is assigned a special value of NULL is a variable of type null.
2. A specific built-in function (such as a database function) returns a variable of type resource.
You can then use a forced type conversion like C, such as
$a=6.66666;$b=(integer)$a;echo$b;
Will output a 6, directly out of the decimal part
2. Use float floor (float value) function
The rounding method takes the whole, returns the next integer not less than value, and the fractional part of value is rounded off. The type returned by floor () is still float, because the range of float values is usually larger than the integer.
floor(4.3); // 输出4 floor(9.999// 输出9
3. Using the float ceil (float value) function
Returns the next integer not less than value, in which value is entered if there is a fractional part. The type returned by Ceil () is still float, because the range of float values is usually larger than the integer.
ceil(4.3); // 输出5 ceil(9.999); // 输出10
4. Use float round (float val [, int precision]) function
Rounds a floating-point number, returning the result of rounding Val based on the specified precision precision (the number of digits after the decimal point). Precision can also be negative or 0 (the default value).
round(3.4); // 输出3 round(3.5); // 输出4 round(3.6); // 输出4 round(3.60); // 输出4 round(1.955832); // 输出1.96 round(1241757, -3// 输出1242000 round(5.0452); // 输出5.04 round(5.0552); // 输出5.06
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above is introduced 5, php-floating point to integer, including the content of PHP, floating point, I hope the PHP tutorial interested in a friend helpful.