# How To Use PHP Maths Function Example ?

03-Apr-2023

. Hi guys,

Today i will explained how to use php Maths function in your php file. This example is so easy to use in php. This example to i am use in many Maths function in php file.

THe maths function is provided in a php in by default. Maths function use to vary easy here.

This example to i am use in pi(),min(),max(),abs(),sqrt(),round(),rand() function used in this tutorial. So you are follow for my step by step.

So let's start to the example.

Pi() Function Example

```<?php
echo(pi());
echo "<br>";
// returns 3.1415926535898
?>
```

Output

`3.1415926535898`

Min() and Max() Function Example

Min() and Max() function is return to the minimun and maximum value return in the list

```<?php
echo(min(0, 150, 30, 20, -8, -200));
echo "<br>";
// returns -200

echo(max(0, 150, 30, 20, -8, -200));
echo "<br>";
// returns 150
?>
```

Output

```Min : -200
Max : -200
```

Abs() Function Example

```<?php
echo(abs(-6.7));
echo "<br>";
// returns 6.7
?>
```

Output

`6.7`

Sqrt() Function Example

Sqrt() function is return the square root of a number.

```<?php
echo(sqrt(64));
echo "<br>";
// returns 8
?>
```

Output

`8`

Round() Function Example

Round() function is return the floating-point to nearest integer.

```<?php
echo(round(0.60));
echo "<br>";
// returns 1

echo(round(0.49));
echo "<br>";
// returns 0
?>
```

Output

```Round :1
Round :0
```

Rand() Function Example

Rand() function generates a random number and you are defind to minimum and maximum value defined then number generates in your number.

```<?php
echo(rand());
echo "<br>";
// return 585927897

echo(rand(10, 100));
echo "<br>";
// return 10
?>
```

Output

```Rand :585927897
Rand :10
```

Now you can check your own.