PHP Pow() Function

What we are going to see through this article is PHP Pow() Function. The pow () function in PHP is used to calculate the elevated base per layer power.

This is a common function that can be used with any number elevated to any value. It takes both the base and layer parameters and gives the desired answer.

This is a syntax of pow() built-in function to do a task below:

number pow($base(x), $exponent(y))
PHP Pow() Function

PHP Pow() Function

<?php
echo(pow(3,9) . "<br>");
echo(pow(-4,6) . "<br>");
echo(pow(-5,-3) . "<br>");
echo(pow(-6,-5.8));
?>

We have to provide four different types of base and exponent input values to test this program. Those are:

  • both positive base and exponent,
  • negative base and positive exponent,
  • both negative integer base and exponent,
  • negative integer base and negative float exponent.

Read Also: PHP Sum() Function

Output

pow(3,9) = 19683
pow(-4,6) = 4096
pow(-5,-3) = -0.008
pow(-6,-5.8) = NAN

Conclusion

What we learned through this article is PHP Pow() Function. Also if you have any doubts please leave a comment via the comment box. And we ask that you benefit everyone who shared this article with your friends.

Leave a Comment