Encodera

Thanks for reading!

Donate to the site — we work hard for you.

PHP reference

pow

Raises a number to a power.

Syntax

pow(mixed $num, mixed $exponent): int|float

Parameters

ParameterTypeDescription
$nummixedThe base.
$exponentmixedThe exponent.

Return value

int|floatThe result of the exponentiation.

Examples

The function and the operator give the same result:

<?php
 
echo pow(2, 10), "\n";
echo 2 ** 10;

Output:

1024
1024

A fractional power is a root:

<?php
 
echo pow(27, 1 / 3);

Output:

3

Notes

New code usually uses the ** operator — it is shorter.

See also

  • sqrt — Returns the square root of a number.
  • intdiv — Performs integer division.

In the tutorial

  • Numbers and maths — PHP's maths functions — rounding, number formatting, random numbers and the precision of fractions.

Thanks for reading!

Donate to the site — we work hard for you.