Open In App

PHP Math Functions Complete Reference

The predefined math functions in PHP are used to handle the mathematical operations within the integer and float types. These math functions are part of the PHP core. 

Installation: These functions have not required any installation. The complete list of PHP math functions are given below:



Example: Programs illustrate the decbin() function in PHP:




<?php
echo decbin(12);
?>

Output:



1100
 

The complete list of Math Functions are given below:

PHP math Function

Description

Example

abs() Return the absolute (positive) value of a number.
Try
acos() Find the arc cosine of a number in radians.
Try
acosh() Find the inverse hyperbolic cosine of a number passed to it as an argument. 
Try
asin() Find the arc sine of a number in radians.
Try
asinh() Find the inverse hyperbolic sine of a number passed to it as an argument.
Try
atan2() Calculate the arc tangent of two variables x and y passed to it as arguments.
Try
atan() Return tangent of an argument passed to it which has as a numeric value between -Pi/2 and Pi/2 radians.
Try
atanh() Return tangent of a number passed to it as an argument.
Try
base_convert() Convert a number given in an arbitrary base to a desired base.
Try
bindec() Return the decimal equivalent of the binary number
Try
ceil() This is used to round a number to the nearest greater integer.
Try
cos() Find the cosine of a number.
Try
cosh() Find the hyperbolic sine of an angle.
Try
decbin() Return a string containing a binary representation of the given decimal number argument.
Try
dechex() Convert a given decimal number to an equivalent hexadecimal number.
Try
decoct() Return the octal equivalent of a decimal number.
Try
deg2rad() Convert from degrees to radian, this is where the method deg2rad() comes in aid.
Try
exp() Calculate e raised to the power of the given argument.
Try
expm1()  Calculate e raised to the power of the given argument minus one.
Try
fmod() Calculate the Modulo of any division 
Try
hexdec() Converts a hexadecimal number to a decimal number
Try
hypot() Returns the square root of sum of the an square of arguments passed
Try
intdiv() Returns the integer quotient of the division of the given dividend and divisor. 
Try
is_finite() Check whether a given input value is finite or not.
Try
is_infinite() Takes a single parameter which is a float that is to be checked.
Try
is_nan() Checks whether a value is ‘not a number’.
Try
log10() Calculates the base 10 logarithm of a number
Try
log() Calculates the base 10 logarithms of a number
Try
max() Return the maximum value in an array.
Try
min() Return the lowest value in an array. 
Try
mt_rand() Generates a random integer between the specified minimum and maximum values
Try
octdec() Calculate the decimal equivalent of an octal number. 
Try
pi() Return the value of π.
Try
pow() It is used with a number raised to any value.
Try
rad2deg() Represents an angle in Radians.
Try
rand()  Generate a random integer. 
Try
round( Round a floating-point number
Try
sin() Find the sine value of a number.
Try
sinh() Find the hyperbolic sine of an angle.
Try
sqrt() Calculate the square root of a number. 
Try
srand() Seed the random number generator rand(). 
Try
tan() Find the tangent of the argument parameter.
Try
tanh() Find the hyperbolic tangent of an angle passed to it as a parameter.
Try

Article Tags :