当前位置: 首页 > 网络学院 > 服务端脚本教程 > PHP > PHP Math
The math functions can handle values within the range of integer and float types.
这些数学函数仅能处理在你计算机上 integer 和 float 范围内的值
The math functions are part of the PHP core. There is no installation needed to use these functions.
本函数库作为 PHP 内核的一部分,不用安装就能使用。
PHP: indicates the earliest version of PHP that supports the function.
PHP:最早支持这些函数的PHP版本
| Function | Description | PHP |
|---|---|---|
| abs() | Returns the absolute value of a number 绝对值 | 3 |
| acos() | Returns the arccosine of a number 反余弦 | 3 |
| acosh() | Returns the inverse hyperbolic cosine of a number 反双曲余弦 | 4 |
| asin() | Returns the arcsine of a number 反正弦 | 3 |
| asinh() | Returns the inverse hyperbolic sine of a number 反双曲正弦 | 4 |
| atan() | Returns the arctangent of a number as a numeric value between -PI/2 and PI/2 radians 反正切 | 3 |
| atan2() | Returns the angle theta of an (x,y) point as a numeric value between -PI and PI radians 两个参数的反正切 | 3 |
| atanh() | Returns the inverse hyperbolic tangent of a number 反双曲正切 | 4 |
| base_convert() | Converts a number from one base to another 在任意进制之间转换数字 | 3 |
| bindec() | Converts a binary number to a decimal number 二进制转换为十进制 | 3 |
| ceil() | Returns the value of a number rounded upwards to the nearest integer 进一法取整 | 3 |
| cos() | Returns the cosine of a number 余弦 | 3 |
| cosh() | Returns the hyperbolic cosine of a number 双曲余弦 | 4 |
| decbin() | Converts a decimal number to a binary number 十进制转换为二进制 | 3 |
| dechex() | Converts a decimal number to a hexadecimal number 十进制转换为十六进制 | 3 |
| decoct() | Converts a decimal number to an octal number 十进制转换为八进制 | 3 |
| deg2rad() | Converts a degree to a radian number 将角度转换为弧度 | 3 |
| exp() | Returns the value of Ex 计算 e(自然对数的底)的指数 | 3 |
| expm1() | Returns the value of Ex - 1 返回 exp(number) - 1,甚至当 number 的值接近零也能计算出准确结果 | 4 |
| floor() | Returns the value of a number rounded downwards to the nearest integer 舍去法取整 | 3 |
| fmod() | Returns the remainder (modulo) of the division of the arguments 返回除法的浮点数余数 | 4 |
| Returns the maximum random number that can be returned by a call to the rand() function 显示随机数最大的可能值 | 3 | |
| hexdec() | Converts a hexadecimal number to a decimal number 十六进制转换为十进制 | 3 |
| hypot() | Returns the length of the hypotenuse of a right-angle triangle 计算一直角三角形的斜边长度 | 4 |
| is_finite() | Returns true if a value is a finite number 判断是否为有限值 | 4 |
| is_infinite() | Returns true if a value is an infinite number 判断是否为无限值 | 4 |
| is_nan() | Returns true if a value is not a number 判断是否为合法数值 | 4 |
| lcg_value() | Returns a pseudo random number in the range of (0,1) 组合线性同余发生器 | 4 |
| log() | Returns the natural logarithm (base E) of a number 自然对数 | 3 |
| log10() | Returns the base-10 logarithm of a number 以 10 为底的对数 | 3 |
| log1p() | Returns log(1+number) 返回 log(1 + number),甚至当 number 的值接近零也能计算出准确结果 | 4 |
| max() | Returns the number with the highest value of two specified numbers 找出最大值 | 3 |
| min() | Returns the number with the lowest value of two specified numbers 找出最小值 | 3 |
| mt_getrandmax() | Returns the largest possible value that can be returned by mt_rand() 显示随机数的最大可能值 | 3 |
| mt_rand() | Returns a random integer using Mersenne Twister algorithm 产生一个随机整数 using Mersenne Twister algorithm 生成更好的随机数 | 3 |
| mt_srand() | Seeds the Mersenne Twister random number generator 播下一个更好的随机数发生器种子 | 3 |
| octdec() | Converts an octal number to a decimal number 八进制转换为十进制 | 3 |
| pi() | Returns the value of PI 得到圆周率值 | 3 |
| pow() | Returns the value of x to the power of y 返回指数表达式的值,即:x的y次方 | 3 |
| rad2deg() | Converts a radian number to a degree 将弧度数转换为相应的角度数 | 3 |
| rand() | Returns a random integer 产生一个随机整数 | 3 |
| round() | Rounds a number to the nearest integer 对浮点数进行四舍五入取整 | 3 |
| sin() | Returns the sine of a number 正弦 | 3 |
| sinh() | Returns the hyperbolic sine of a number 双曲正弦 | 4 |
| sqrt() | Returns the square root of a number 平方根 | 3 |
| srand() | Seeds the random number generator 播下随机数发生器种子 | 3 |
| tan() | Returns the tangent of an angle 正切 | 3 |
| tanh() | Returns the hyperbolic tangent of an angle 双曲正切 | 4 |
PHP: indicates the earliest version of PHP that supports the constant.
PHP:最早支持这些常量的PHP版本
| Constant 常量 | Description 说明 | PHP |
|---|---|---|
| M_E | Returns e (approx. 2.718) 返回自然对数底(值大约为:2.718) | 4 |
| M_EULER | Returns Euler's constant (approx. 0.577) 欧拉常数(值大约为:0.57721566490153286061) | 4 |
| M_LNPI | Returns the natural logarithm of PI (approx. 1.144) | 4 |
| M_LN2 | Returns the natural logarithm of 2 (approx. 0.693) 返回2的自然对数(值大约为:0.693) | 4 |
| M_LN10 | Returns the natural logarithm of 10 (approx. 2.302) 返回10的自然对数(值大约为:2.302) | 4 |
| M_LOG2E | Returns the base-2 logarithm of E (approx. 1.442) 返回E对应的以2为底的自然对数(值大约为:1.442) | 4 |
| M_LOG10E | Returns the base-10 logarithm of E (approx. 0.434) 返回E对应的以10为底的自然对数(值大约为:0.434) | 4 |
| M_PI | Returns PI (approx. 3.14159) 返回PI(值大约为:3.14159) | 3 |
| M_PI_2 | Returns PI/2 (approx. 1.570) 返回PI/2(值大约为:1.570) | 4 |
| M_PI_4 | Returns PI/4 (approx. 0.785) 返回PI/4(值大约为:0.785) | 4 |
| M_1_PI | Returns 1/PI (approx. 0.318) 返回1/PI(值大约为:0.318) | 4 |
| M_2_PI | Returns 2/PI (approx. 0.636) 返回2/PI(值大约为:0.636) | 4 |
| M_SQRTPI | Returns the square root of PI (approx. 1.772) 返回PI的平方根(值大约为:1.772) | 4 |
| M_2_SQRTPI | Returns 2/square root of PI (approx. 1.128) 返回PI的平方根的两倍倒数(值大约为:1.128) | 4 |
| M_SQRT1_2 | Returns the square root of 1/2 (approx. 0.707) 返回1/2的平方根(值大约为:0.707) | 4 |
| M_SQRT2 | Returns the square root of 2 (approx. 1.414) 返回2的平方根(值大约为:1.414) | 4 |
| M_SQRT3 | Returns the square root of 3 (approx. 1.732) 返回3的平方根(值大约为:1.732) | 4 |
评论 (0) All