pow
Raises a number to a power.
Syntax
pow(mixed $num, mixed $exponent): int|floatParameters
| Parameter | Type | Description |
|---|---|---|
| $num | mixed | The base. |
| $exponent | mixed | The 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
1024A fractional power is a root:
<?php
echo pow(27, 1 / 3);Output:
3Notes
New code usually uses the ** operator — it is shorter.
See also
In the tutorial
- Numbers and maths — PHP's maths functions — rounding, number formatting, random numbers and the precision of fractions.