The PHP has a number of math functions that are available to use. These functions are listed below in alphabetical order. For more details about any one of these, please visit its page.
Functions | Description |
abs() |
Returns the absolute (positive) value of the given number. |
base_convert() | Converts a number from one number base to another |
bindec() |
Returns the decimal equivalent of the binary number represented by the binary string argument. |
ceil() |
Rounds the given number up to the nearest integer. |
decbin() |
Returns a string which is the binary representation of a decimal number. |
dechex() |
Returns a string which is the hexadecimal representation of a decimal number. |
decoct() |
Returns a string which is the octal representation of a decimal number. |
deg2rad() |
Converts an angle in degrees to an angle in radians. |
floor() |
Rounds the given number down to the nearest integer. |
fmod() |
Returns remainder of the division of arguments. |
getrandmax() | Returns the largest possible value returned by rand() |
hexdec() |
Returns the decimal equivalent of the hexadecimal number represented by the hexadecimal string argument. |
intdiv() |
Performs integer division |
is_finite() |
Checks whether a value is finite or not |
is_infinite() |
Checks whether a value is infinite or not |
is_nan() |
Checks whether a value is 'not-a-number' |
lcg_value() | Returns a pseudo random number in a range between 0 and 1 |
max() |
Returns the maximum value in an array, or the maximum value among specified values. |
min() |
Returns the minimum value in an array, or the minimum value among specified values. |
mt_getrandmax() | Returns the largest possible value returned by mt_rand() |
mt_rand() | Generates a random integer using Mersenne Twister algorithm |
mt_srand() | Seeds the Mersenne Twister random number generator |
octdec() |
Returns the decimal equivalent of the octal number represented by the octal string argument. |
pi() |
Returns the value of PI. |
pow() |
Returns base raised to the power of exponent. |
rad2deg() |
Converts an angle in radians to an angle in degrees. |
rand() |
Generates a random integer |
round() |
Returns the rounded version of a floating-point number |
sqrt() |
Returns the square root of the given number. |
srand() | Seeds the random number generator |
Functions | Description |
sin() |
Returns the trigonometric sine of an angle. |
cos() |
Returns the trigonometric cosine of an angle. |
tan() |
Returns the trigonometric tangent of an angle. |
asin() |
Returns the arc sine of a value. |
acos() |
Returns the arc cosine of a value. |
atan() |
Returns the arc tangent of a value. |
atan2() |
Returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta). |
hypot() |
Returns square root of sum of squares of two arguments, i.e., sqrt(x2 +y2). |