I.Numeric data type
Numeric or numeric data are generally two types of double and INT in PHP.
PHP is a loose scripting language. Pay attention to the type conversion method.
<? PHP $='5'; //The string of a number is also a number. It is used in mathematical operations as a number. EchoIs_numeric ($);// 1 Echo'<Br/>'; Echo7+$;// 12 Echo'<Br/>'; Echo'7'+$;// 12 Echo'<Br/>'; //Use.After connection, it will be processed by string Echo'7'.$;// 75 ?> |
II.Random Number
Rand ()A function is a simple package of a random function defined in libc.
Mt_rand ()Function is a good alternative to implementation.
<? PHP $= Rand (0,10); Echo$; Echo'<Br/>'; EchoGetrandmax (); Echo'<Br/>'; $ B= Mt_rand (0,10); Echo$ B; Echo'<Br/>'; EchoMt_getrandmax (); Echo'<Br/>'; ?> |
Output
3..Format data
<? PHP $=12345.6789; //Used to set the number of decimal points retained EchoNumber_format ($,2); Echo'<Br/>'; //You can also change the default decimal point and kilobytes. EchoNumber_format ($,2,'#','*') ?> |
Output
Iv. mathematical functions
Function |
Function |
ABS () |
Take absolute value |
Floor () |
Rounding |
Ceil () |
Returns an integer. |
Round () |
Rounding |
Min () |
Minimum value or the minimum value in the array |
Max () |
Returns the maximum value or the maximum value in the array. |
<? PHP $=-123456.789; $ B=Array(1,2,3,4); EchoABS ($); Echo'<Br/>'; EchoFloor ($); Echo'<Br>'; EchoCeil ($); Echo'<Br>'; EchoRound ($); Echo'<Br>'; EchoMin ($ B); Echo'<Br>'; EchoMax ($ B); ?> |
Output
123456.789 -123457 -123456 -123457 1 4 |