助力软件开发企业降本增效 PHP / java源码系统,只需一次付费,代码终身使用! 广告
# PHP Math 函数 ## PHP Math 简介 数学 (Math) 函数能处理 integer 和 float 范围内的值。 ## 安装 数学 (Math) 函数是 PHP 核心的组成部分。无需安装即可使用这些函数。 ## PHP Math 函数 PHP:指示支持该函数的最早的 PHP 版本。 | 函数 | 描述 | PHP | | --- | --- | --- | | [abs()](func_math_abs.asp) | 绝对值。 | 3 | | [acos()](func_math_acos.asp) | 反余弦。 | 3 | | [acosh()](func_math_acosh.asp) | 反双曲余弦。 | 4 | | [asin()](func_math_asin.asp) | 反正弦。 | 3 | | [asinh()](func_math_asinh.asp) | 反双曲正弦。 | 4 | | [atan()](func_math_atan.asp) | 反正切。 | 3 | | [atan2()](func_math_atan.asp) | 两个参数的反正切。 | 3 | | [atanh()](func_math_atanh.asp) | 反双曲正切。 | 4 | | [base_convert()](func_math_base_convert.asp) | 在任意进制之间转换数字。 | 3 | | [bindec()](func_math_bindec.asp) | 把二进制转换为十进制。 | 3 | | [ceil()](func_math_ceil.asp) | 向上舍入为最接近的整数。 | 3 | | [cos()](func_math_cos.asp) | 余弦。 | 3 | | [cosh()](func_math_cosh.asp) | 双曲余弦。 | 4 | | [decbin()](func_math_decbin.asp) | 把十进制转换为二进制。 | 3 | | [dechex()](func_math_dechex.asp) | 把十进制转换为十六进制。 | 3 | | [decoct()](func_math_decoct.asp) | 把十进制转换为八进制。 | 3 | | [deg2rad()](func_math_deg2rad.asp) | 将角度转换为弧度。 | 3 | | [exp()](func_math_exp.asp) | 返回 E<sup>x</sup> 的值。 | 3 | | [expm1()](func_math_expm1.asp) | 返回 E<sup>x</sup> - 1 的值。 | 4 | | [floor()](func_math_floor.asp) | 向下舍入为最接近的整数。 | 3 | | [fmod()](func_math_fmod.asp) | 返回除法的浮点数余数。 | 4 | | [getrandmax()](func_math_getrandmax.asp) | 显示随机数最大的可能值。 | 3 | | [hexdec()](func_math_hexdec.asp) | 把十六进制转换为十进制。 | 3 | | [hypot()](func_math_hypot.asp) | 计算直角三角形的斜边长度。 | 4 | | [is_finite()](func_math_is_finite.asp) | 判断是否为有限值。 | 4 | | [is_infinite()](func_math_is_infinite.asp) | 判断是否为无限值。 | 4 | | [is_nan()](func_math_is_nan.asp) | 判断是否为合法数值。 | 4 | | [lcg_value()](func_math_lcg_value.asp) | 返回范围为 (0, 1) 的一个伪随机数。 | 4 | | [log()](func_math_log.asp) | 自然对数。 | 3 | | [log10()](func_math_log10.asp) | 以 10 为底的对数。 | 3 | | [log1p()](func_math_log1p.asp) | 返回 log(1 + number)。 | 4 | | [max()](func_math_max.asp) | 返回最大值。 | 3 | | [min()](func_math_min.asp) | 返回最小值。 | 3 | | [mt_getrandmax()](func_math_mt_getrandmax.asp) | 显示随机数的最大可能值。 | 3 | | [mt_rand()](func_math_mt_rand.asp) | 使用 Mersenne Twister 算法返回随机整数。 | 3 | | [mt_srand()](func_math_mt_srand.asp) | 播种 Mersenne Twister 随机数生成器。 | 3 | | [octdec()](func_math_octdec.asp) | 把八进制转换为十进制。 | 3 | | [pi()](func_math_pi.asp) | 返回圆周率的值。 | 3 | | [pow()](func_math_pow.asp) | 返回 x 的 y 次方。 | 3 | | [rad2deg()](func_math_rad2deg.asp) | 把弧度数转换为角度数。 | 3 | | [rand()](func_math_rand.asp) | 返回随机整数。 | 3 | | [round()](func_math_round.asp) | 对浮点数进行四舍五入。 | 3 | | [sin()](func_math_sin.asp) | 正弦。 | 3 | | [sinh()](func_math_sinh.asp) | 双曲正弦。 | 4 | | [sqrt()](func_math_sqrt.asp) | 平方根。 | 3 | | [srand()](func_math_srand.asp) | 播下随机数发生器种子。 | 3 | | [tan()](func_math_tan.asp) | 正切。 | 3 | | [tanh()](func_math_tanh.asp) | 双曲正切。 | 4 | ## PHP Math 常量 | 常量名 | 常量名 | 常量值 | PHP | | --- | --- | --- | --- | | M_E | e | 2.7182818284590452354 | 4 | | M_EULER | Euler 常量 | 0.57721566490153286061 | 5.2.0 | | M_LNPI | log_e(pi) | 1.14472988584940017414 | 5.2.0 | | M_LN2 | log_e 2 | 0.69314718055994530942 | 4 | | M_LN10 | log_e 10 | 2.30258509299404568402 | 4 | | M_LOG2E | log_2 e | 1.4426950408889634074 | 4 | | M_LOG10E | log_10 e | 0.43429448190325182765 | 4 | | M_PI | Pi | 3.14159265358979323846 | 3 | | M_PI_2 | pi/2 | 1.57079632679489661923 | 4 | | M_PI_4 | pi/4 | 0.78539816339744830962 | 4 | | M_1_PI | 1/pi | 0.31830988618379067154 | 4 | | M_2_PI | 2/pi | 0.63661977236758134308 | 4 | | M_SQRTPI | sqrt(pi) | 1.77245385090551602729 | 5.2.0 | | M_2_SQRTPI | 2/sqrt(pi) | 1.12837916709551257390 | 4 | | M_SQRT1_2 | 1/sqrt(2) | 0.70710678118654752440 | 4 | | M_SQRT2 | sqrt(2) | 1.41421356237309504880 | 4 | | M_SQRT3 | sqrt(3) | 1.73205080756887729352 | 5.2.0 |