PHP Math function
1- rand()

This function generates random number.

Return Type :- int

<?php
echo rand(1,10);
?>

Output:-
3

2- max()

This function returns highest value

Return Type :- mixed

<?php
echo max(15,10,2);
?>

Output :-
15

3- min()

This function returns lowest value.

Return Type :- mixed

<?php
echo min(15,10,2);
?>

Output :-
2

4- floor()

This function returns the nearest interger in down direction. menas -5.9 is near -6 in downward and 6.7 is 6 is down direction.

Return Type :- float

<?php
echo floor(46.9);
echo "<br>";
echo floor(-7.8);
?>

Output :-
46
-8

5- sqrt()

This function returns the squareroot of the number.

Return Type :- float

<?php
echo sqrt(9);
?>

Output :-
3

6- round()

This function returns the value nearest the interger.

Return Type :- float

<?php
echo round(8.5);
echo "<br>";
echo round(-85.8);
?>

Output :-
9
-86

Previous
Next