pow()

aryamehrian's avatar
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:

Code
Output
Loading...

All contributors

Contribute to Docs

Learn PHP on Codecademy