pow()
pow() — Exponential expression.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
Returns num raised to the power of exponent.
Signature
pow(mixed $num, mixed $exponent): int|float|object
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $num | mixed | The base to use |
| $exponent | mixed | The exponent |
Return value
num raised to the power of exponent. If both arguments are non-negative integers and the result can be represented as an integer, the result will be returned with int type, otherwise it will be returned as a float. PHP-Extensions may override the behaviour of this operation and make it return an object.
Example
A runnable snippet:
var_dump(pow(2, 8)); // int(256) echo pow(-1, 20), PHP_EOL; // 1 echo pow(0, 0), PHP_EOL; // 1 echo pow(10, -1), PHP_EOL; // 0.1 echo pow(-1, 5.5), PHP_EOL; // NAN
Changelog
| Version | Change |
|---|---|
| 8.4.0 | Raising 0 to a negative exponent is now deprecated. |
See also
All PHP 8.5 built-in functions
Reference card built from the PHP manual page pow() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.