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:

<?php
echo "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:

us
Visit us
code
Hide code
Code
Output
Hide output
Hide output
Loading...

All contributors

Looking to contribute?

Learn PHP on Codecademy