PHP has built-in math functions to perform math operations on integers and
floats. These functions are part of PHP's core, so no installation is needed.
Below is a list of some common PHP math functions.
Here is an example of how to use the
`decbin()` function in PHP:<?php echo decbin(12); ?>
Output:
1100
The complete list of Math Functions are given below:
| PHP Math Functions | Description |
|---|---|
| abs() | Return the absolute (positive) value of a number. |
| acos() | Find the arc cosine of a number in radians. |
| acosh() | Find the inverse hyperbolic cosine of a number passed to it as an argument. |
| asin() | Find the arc sine of a number in radians. |
| asinh() | Find the inverse hyperbolic sine of a number passed to it as an argument. |
| atan2() | Calculate the arc tangent of two variables x and y passed to it as arguments. |
| atan() | Return tangent of an argument passed to it which has as a numeric value between -Pi/2 and Pi/2 radians. |
| atanh() | Return tangent of a number passed to it as an argument. |
| base_convert() | Convert a number given in an arbitrary base to a desired base. |
| bindec() | Return the decimal equivalent of the binary number. |
| ceil() | This is used to round a number to the nearest greater integer. |
| cos() | Find the cosine of a number. |
| cosh() | Find the hyperbolic sine of an angle. |
| decbin() | Return a string containing a binary representation of the given decimal number argument. |
| dechex() | Convert a given decimal number to an equivalent hexadecimal number. |
| decoct() | Return the octal equivalent of a decimal number. |
| deg2rad() | Convert from degrees to radians. |
| exp() | Calculate e raised to the power of the given argument. |
| expm1() | Calculate e raised to the power of the given argument minus one. |
| fmod() | Calculate the modulo of any division. |
| hexdec() | Converts a hexadecimal number to a decimal number. |
| hypot() | Returns the square root of the sum of the squares of arguments passed. |
| intdiv() | Returns the integer quotient of the division of the given dividend and divisor. |
| is_finite() | Check whether a given input value is finite or not. |
| is_infinite() | Takes a single parameter which is a float that is to be checked for infinity. |
| is_nan() | Checks whether a value is 'not a number'. |
| log10() | Calculates the base 10 logarithm of a number. |
| log() | Calculates the base-e (natural) logarithm of a number. |
| max() | Return the maximum value in an array. |
| min() | Return the lowest value in an array. |
| mt_rand() | Generates a random integer between the specified minimum and maximum values. |
| octdec() | Calculate the decimal equivalent of an octal number. |
| pi() | Return the value of PI (π). |
| pow() | It is used to calculate a number raised to a power. |
| rad2deg() | Convert from radians to degrees. |
| rand() | Generate a random integer. |
| round() | Round a floating-point number to a specified precision. |
| sin() | Find the sine value of a number. |
| sinh() | Find the hyperbolic sine of an angle. |
| sqrt() | Calculate the square root of a number. |
| srand() | Seed the random number generator rand(). |
| tan() | Find the tangent of the argument parameter. |
| tanh() | Find the hyperbolic tangent of an angle passed to it as a parameter. |
