Math Functions

Published Apr 20, 2023
Contribute to Docs

PHP has several built-in functions for performing mathematical operations.

A list of PHP math operation functions can be found in the table below:

Math Functions

abs()
Returns the absolute value of the argument.
acos()
Returns the angle whose cosine value is equal to the specified value.
acosh()
Returns the inverse hyperbolic cosine value of the given argument.
asin()
Returns the arc sine of a given number.
asinh()
Returns the inverse hyperbolic sine of a number.
atan()
Returns the angle whose tangent is equal to the specified value.
atan2()
Returns the arc tangent of y/x, in radians.
atanh()
Returns the inverse hyperbolic tangent of a given value.
base_convert()
Converts a number from one number base to another.
bindec()
Returns an integer representing the decimal value of the binary string passed as input.
ceil()
Returns the next highest integer value of the fractional argument.
cos()
Returns the cosine of the angle passed as the argument.
cosh()
Returns the hyperbolic cosine of a number.
decbin()
Converts a decimal number to a string containing a binary number.
dechex()
Returns a hexadecimal string representation of a decimal number.
decoct()
Returns the corresponding octal value of the given decimal value.
deg2rad()
Converts a number in degrees to the radian equivalent.
exp()
Returns e raised to the power of x.
floor()
Returns a rounded number down to the nearest integer.
fmod()
Returns the remainder (modulo) of x/y.
hexdec()
Returns the decimal equivalent of a given hexadecimal string.
hypot()
Returns the length of the hypotenuse of a 90-degree triangle.
is_finite()
Evaluates whether a value is a legal finite number or not.
is_infinite()
Evaluates whether a value is an infinite number or not.
is_nan()
Checks whether a value is not a number.
log()
Returns the natural logarithm of a value.
log10()
Returns the base-10 logarithm of a number.
max()
Finds and returns the highest value in an array or a list of variables.
min()
Returns the lowest value out of a group or array of values.
octdec()
Converts octal numbers to decimal numbers.
pi()
Returns the value of PI.
pow()
Returns the number raised to the power of the exponent.
rad2deg()
Converts radians to degrees.
round()
Returns the nearest whole number to the passed value, or the value rounded to the specified decimal precision.
sin()
Returns the sine of a given angle.
sinh()
Returns the hyperbolic sine of a number.
sqrt()
Calculates the square root of a number.
tan()
Returns the tangent of the angle passed as the argument.
tanh()
Returns the hyperbolic tangent of a number.

All contributors

Looking to contribute?

Learn PHP on Codecademy