Math in PHP, has in-built math functions, which makes mathematical operations easier.
Math functions | Description |
---|---|
abs | Returns absolute value |
bindec | Converts a binary into decimal number |
exp | Returns e to the power of n (where n is given number) |
is_nan | Checks given value is number or not |
is_finite | Checks given value is finite or not |
is_infinite | Checks given value is infinite or not |
max | Returns the highest value from given numbers |
min | Returns the lowest value from given numbers |
octdec | Converts a octal into decimal number |
pi | Gives the value of PI |
pow | Returns the power of given number. |
sqrt | Returns the square root of given number. |
abs
<?php
$a = -20;
echo abs($a);
?>
pi
<?php
echo pi();
?>
pow
<?php
$p = 3;
$n = 20;
echo pow($n, $p);
?>
sqrt
<?php
$p = 3;
$n = 20;
echo sqrt($n, $p);
?>