pow

Exponential expression

Syntax

pow ( number $base , number $exp ) : number

Parameters

base

The base to use

exp

The exponent

Return

base raised to the power of exp. If both arguments are non-negative integers and the result can be represented as an integer, the result will be returned with integer type, otherwise it will be returned as a float.

Examples

1

<?

$base = 2;
$exp = -4;

$return = pow($base, $exp);

echo $return;

?>
0.0625

2

<?

$base = 2;
$exp = 4;

$return = pow($base, $exp);

echo $return;

?>
16

3

<?

echo 2 ** -4 . PHP_EOL;
echo 2 ** 4;

?>
0.0625
16
HomeMenu