Home  >  Article  >  Backend Development  >  Summary of nine mathematical functions in php

Summary of nine mathematical functions in php

不言
不言Original
2018-08-21 15:51:382137browse

This article brings you a summary of nine mathematical functions in PHP. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

1. Find the maximum value max()

echo max(array(4,5,6)); //6

2. Find the minimum value min()

echo min(array(4,5,6)); //4

3. Find the square root sqrt()

echo sqrt(16); //4

4. Rounding of floating point numbers round()

Pass in two parameters

echo round(3.725, 2); //3.73, 参数(2)保留小数点后多少位,默认为0 舍入后的结果

5. Return the nth power of the number pow()

echo pow(2,3);// 8

6. Removal method and rounding floor();

echo floor(7.88888); //7 浮点数直接舍去小数部分

7. Further rounding method ceil()

echo ceil(9.111); // 10 浮点数进一取整

8. Find the absolute value abs()

$abs = abs(-9.9); //9.9数字绝对值数字

9. Random number mt_rand()

echo mt_rand(0,100);//n->随机数随机返回范围内的值

Related recommendations:

Summary of commonly used mathematical functions in php, summary of mathematical functions

PHP function learning PHP function comments

The above is the detailed content of Summary of nine mathematical functions in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn