Math Functions in PHP

Math Functions in PHP
Rating: 5 - 1 Votes

Math Functions in PHP

phpApart from arithmetic operators, we also have Math functions in PHP.  Click Here for list of Math functions in PHP.  There are few commonly used Math functions given below.

Is_int:  This function will check if the passed value is integer or not and return true or false.

Is_float:  This function will check if the passed value is float or not and return true or false.

Is_numeric:  This function will check if the passed value is numeric or not and return true or false.  Both float and integer are considered as numeric.

Rand:  This function will return random value. We do have overloaded version of this function which will take min and max value as parameter and return the random value within that range.

Round:  This function will take 2 parameters, a float and an integer which will determine how much digits you want after the decimal.

Pow:  This is also known as exponential expression. It will take 2 integers as parameter, base and exponent.  Base will act as power to the exponent.

Sqrt:  This function will return square root value.

Fmod:  This function is similar to arithmetic operator modulus (%). This function will return remainder of the division.

Abs:  This function will return the absolute value of an integer or float.

Ceil:  This function will round up the float number.

Floor:  This function will round down the float number.