Home > Backend Development > PHP Tutorial > Summary of nine mathematical functions in php

Summary of nine mathematical functions in php

不言
Release: 2023-04-03 21:10:02
Original
2175 people have browsed it

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
Copy after login

2. Find the minimum value min()

echo min(array(4,5,6)); //4
Copy after login

3. Find the square root sqrt()

echo sqrt(16); //4
Copy after login

4. Rounding of floating point numbers round()

Pass in two parameters

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

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

echo pow(2,3);// 8
Copy after login

6. Removal method and rounding floor();

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

7. Further rounding method ceil()

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

8. Find the absolute value abs()

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

9. Random number mt_rand()

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

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template