Home > Article > Backend Development > Detailed explanation of digital functions in php
This article mainly shares with you the detailed explanation of PHP's digital functions. It mainly explains it in the form of code. I hope it can help you.
floor(值) 向下取整 ceil(值) 向上取整
pow(底数,指数)
Example
// 输出2的3次方 echo pow(2,3); // 8
sqrt(数字)
Example
//输出4的平方根 echo sqrt(4); // 2
rand(start,end) 比较慢,而且有 mt_rand(start,end) 推荐使用,性能好
number_format(数字(,小数位数))
If only numbers are passed in, decimals will not be retained and ## will be added to the thousands place. #, are used as delimiters.
Example
// 格式化 $x = 6789.123; echo number_format($x); // 6,789 echo '<br/>'; echo number_format($x,2); // 6,789.12 echo '<hr/>';Related recommendations:
5. Single-line functions, multi-line functions, character functions, numeric functions, Date function, data type
The above is the detailed content of Detailed explanation of digital functions in php. For more information, please follow other related articles on the PHP Chinese website!