Today, We want to share with you **math function in php**.In this post we will show you **numeric function in php**, hear for *array functions in php* we will give you demo and example for implement.In this post, we will learn about *Introduction To Math Class in C# ASP.NET* with an example.

And Today, we will discuss – “What are PHP MATH Functions?”

## PHP Math Functions

As you know PHP is a sever side script language which is used for making the dynamic web pages.

There are various mathematical functions in PHP. PHP Math Function can be used to perform mathematical operations like as a max(), min(), round() or addition, subtraction, division and multiplication and many other mathematical requirements.

This all the functions can handle values within the range of integer as well as float types.

PHP has nice support for mathematical processing.

## PHP Math Functions: Main Tips

- PHP math functions are used for handling
**float**and**integer**variables. - These functions are inbuilt into PHP.

**Write PHP script to demonstrate math functions.**

"; $first_no=max($first_no,$n3); echo "Max is : $first_no"."

"; $n4=sqrt($first_no); echo "sqrt is : $n4"."

"; $first_no=pow($second_no,$n4); echo "pow is : $first_no"."

"; echo "ceil : ".ceil($first_no)."

"; echo "floor : ".floor($second_no)."

"; echo "round : ".round($n3.$first_no)."

"; echo "abs : ".abs($n4); ?>

Following is an explanation of some interesting PHP Math Functions –

### abs () function

It is a Give backs the absolute (positive) value of a number.

## abs function

'; echo "This abs function User Input is : ".abs ($num); ?>

"); // 7 (integer) echo (abs(7)."

"); //7 (integer) echo (abs(-7.2)."

"); //7.2 (float/double) ?>

### dechex () function

It is a Converts a decimal number to a hexadecimal number.

## dechex function

'; echo "This dechex function User Input is : ".dechex ($num); ?> }

### sqrt() function

It is a Give backs the square root of a number.

## sqrt function

'; echo "This sqrt function User Input is : ".sqrt ($num); ?>

");// 4 echo (sqrt(25)."

");// 5 echo (sqrt(7)."

");// 2.6457513110646 ?>

### log() function

It is a Give backs the natural logarithm of a number.

## log function

'; echo "This log function User Input is : ".log ($num); ?>

### floor() function

It is a Rounds a number down to the nearest integer.

## floor function

'; echo "This floor function User Input is : ".floor ($num).'

'; ?>

");// 3 echo (floor(7.333)."

");// 7 echo (floor(-4.8)."

");// -5 ?>

### ceil() function

It is a Rounds a number up to the nearest integer.

## ceil function

'; echo "This ceil function User Input is : ".ceil ($num).'

'; ?>

");// 4 echo (ceil(7.333)."

");// 8 echo (ceil(-4.8)."

");// -4 ?>

### pow() function

It is a Give backs x raised to the power of y.

## pow function

'; echo "This pow function User Input is : ".pow(2,$num).'

'; echo "This pow function User Input is : ".pow($num,2); ?>

### max() and min() function

These are Give backs the highest value in an array, or the highest value of several specified values as well as Give backs the lowest value in an array, or the lowest value of several specified values.

## max and min function

'; echo "Maximum number is : ".max ($num).'

'; echo "Minimum number is : ".min ($num); ?>

### sin() function

It is a Give backs the sine of a number.

## sin() function

'; echo "Data Content of the sin0 is : ".sin($num); ?>

### cos() function

It is a Give backs the cosine of a number.

## cos() function

'; echo "Data Content of the cos0 is : ".cos($num); ?>

### tan() function

It is a Give backs the tangent of a number.

## tan() function

'; echo "Data Content of the tan45 is : ".tan ($num); ?>

### Mathematical Functions in PHP

In the table below, Let’s see the list of important PHP math functions. All the PHP math functions are listed alphabetically.

Function | Description |
---|---|

abs() | Give backs the absolute (positive) value of a number |

acos() | Give backs the arc cosine of a number |

acosh() | Give backs the inverse hyperbolic cosine of a number |

asin() | Give backs the arc sine of a number |

asinh() | Give backs the inverse hyperbolic sine of a number |

atan() | Give backs the arc tangent of a number in radians |

atan2() | Give backs the arc tangent of two variables x and y |

atanh() | Give backs the inverse hyperbolic tangent of a number |

base_convert() | Converts a number from one number base to another |

bindec() | Converts a binary number to a decimal number |

ceil() | Rounds a number up to the nearest integer |

cos() | Give backs the cosine of a number |

cosh() | Give backs the hyperbolic cosine of a number |

decbin() | Converts a decimal number to a binary number |

dechex() | Converts a decimal number to a hexadecimal number |

decoct() | Converts a decimal number to an octal number |

deg2rad() | Converts a degree value to a radian value |

exp() | Calculates the exponent of e |

expm1() | Give backs exp(x) – 1 |

floor() | Rounds a number down to the nearest integer |

fmod() | Give backs the remainder of x/y |

getrandmax() | Give backs the largest possible value returned by rand() |

hexdec() | Converts a hexadecimal number to a decimal number |

hypot() | Calculates the hypotenuse of a right-angle triangle |

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() | Give backs a pseudo random number in a range between 0 and 1 |

log() | Give backs the natural logarithm of a number |

log10() | Give backs the base-10 logarithm of a number |

log1p() | Give backs log(1+number) |

max() | Give backs the highest value in an array, or the highest value of several specified values |

min() | Give backs the lowest value in an array, or the lowest value of several specified values |

mt_getrandmax() | Give backs 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() | Converts an octal number to a decimal number |

pi() | Give backs the value of PI |

pow() | Give backs x raised to the power of y |

rad2deg() | Converts a radian value to a degree value |

rand() | Generates a random integer |

round() | Rounds a floating-point number |

sin() | Give backs the sine of a number |

sinh() | Give backs the hyperbolic sine of a number |

sqrt() | Give backs the square root of a number |

srand() | Seeds the random number generator |

tan() | Give backs the tangent of a number |

tanh() | Give backs the hyperbolic tangent of a number |

I hope you get an idea about **What is function in general mathematics in PHP?**.

I would like to have feedback on my infinityknow.com blog.

Your valuable feedback, question, or comments about this article are always welcome.

If you enjoyed and liked this post, don’t forget to share.