Math functions deal with the integers and floating values in PHP. On this page, you will find a reference to the important and useful math functions in PHP.
There is no installation required for these functions. These are the parts of the core PHP language.
Function | Description |
---|---|
abs() | Returns the absolute (positive) value of a number |
acos() | Returns the arc cosine of a number |
acosh() | Returns the inverse hyperbolic cosine of a number |
asin() | Get the arcsine of a number |
asinh() | Returns the inverse hyperbolic sine of a number |
atan() | Get the arctangent of a number in radians |
atan2() | Get the arctangent of two variables x and y |
atanh() | Returns the inverse hyperbolic tangent of a number |
base_convert() | Convert a number from one number base to another |
bindec() | Convert a binary number to a decimal number |
ceil() | Round a number up to the nearest integer |
cos() | Returns the cosine of a number |
cosh() | Returns the hyperbolic cosine of a number |
decbin() | Convert a decimal number to a binary number |
dechex() | Convert a decimal number to a hexadecimal number |
decoct() | Convert a decimal number to an octal number |
deg2rad() | Convert a degree value to a radian value |
exp() | Calculate the exponent of e |
expm1() | Returns exp(x) – 1 |
floor() | Round a number down to the nearest integer |
fmod() | Returns the remainder of x/y |
getrandmax() | Returns the largest possible value returned by rand() |
hexdec() | Convert a hexadecimal number to a decimal number |
hypot() | Calculate the hypotenuse of a right-angle triangle |
intdiv() | Perform integer division |
is_finite() | Check whether a value is finite or not |
is_infinite() | Check whether a value is infinite or not |
is_nan() | Check whether a value is ‘not-a-number’ |
lcg_value() | Get a pseudo-random number in a range between 0 and 1 |
log() | Returns the natural logarithm of a number |
log10() | Returns the base-10 logarithm of a number |
log1p() | Returns log(1+number) |
max() | Returns the highest value in an array, or the highest value of several specified values |
min() | Returns the lowest value in an array, or the lowest value of several specified values |
mt_getrandmax() | Returns the largest possible value returned by mt_rand() |
mt_rand() | Generate a random integer using Mersenne Twister algorithm |
mt_srand() | Seed the Mersenne Twister random number generator |
octdec() | Convert an octal number to a decimal number |
pi() | Returns the value of PI |
pow() | Returns x raised to the power of y |
rad2deg() | Convert a radian value to a degree value |
rand() | Generate a random integer |
round() | Round a floating-point number |
sin() | Returns the sine of a number |
sinh() | Returns the hyperbolic sine of a number |
sqrt() | Returns the square root of a number |
srand() | Seed the random number generator |
tan() | Returns the tangent of a number |
tanh() | Returns the hyperbolic tangent of a number |