Home >>PHP Math Functions >PHP pow() Function

PHP pow() Function

PHP pow() Function

PHP pow() function is used to calculate a base raised to the power of exponent. It is a generic function which is used with a given number raised to any specific value. It takes two parameters which are the base and exponent of the function. It returns the given input number raised to the specific power as output. If both the arguments passed to it are non-negative integers then result can be represented as an integer, otherwise it is returned as a float.

Syntax:

  pow($base, $exp);

Parameter Values

Parameter Description
base This is a required parameter. This parameter defines the base to use.
exp This is a required parameter. This parameter defines the exponent.

Here is an example of pow() function in PHP:

<html>
<body>

<?php

echo pow(1,5)."<br>";
echo pow(2,10)."<br>";
echo pow(10,10)."<br>";
echo pow(5,15)."<br>";

?>

</body>
</html>
Output:
1
1024
10000000000
30517578125

Here is another example of pow() function in PHP:

<html>
<body>

<?php

echo pow(-1,3)."<br>";
echo pow(-2,10)."<br>";
echo pow(-5,-5)."<br>";
echo pow(2.4,3)."<br>";
echo pow(5,3.2)."<br>";
echo pow(-5,2.5)."<br>";

?>

</body>
</html>
Output:
-1
1024
-0.00032
13.824
172.46620768265
NAN

No Sidebar ads