pow()
Published Jun 2, 2023
Contribute to Docs
The pow()
function returns the number raised to the power of the exponent.
Syntax
pow($base, $exp)
The pow()
function takes two parameters:
$base
is the number to be raised and $exp
is the power for a base to be raised.
The exponent operator **
can be used instead of this function. pow($base, $exp)
returns the base raised to the exponent, which is the same as $base ** $exp
.
Example
The following example calculates 5^2
:
<?phpecho "pow(5,2) = " . pow(5,2);echo ", using ** operator =". 5**2;?>
This will output:
pow(5,2) = 25, using ** operator = 25
Codebyte Example
The following example calculates 5^0
:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.