Exponentiation in PHP
There is also a special operator
**
for exponentiation. Let's
use it to raise the number 10
to the third
power:
<?php
echo 10 ** 3; // outputs 1000
?>
Let's raise the value of a variable to a power:
<?php
$a = 10;
echo $a ** 3; // outputs 1000
?>
It might be the case that both the number and the exponent are stored in variables:
<?php
$a = 10;
$b = 3;
echo $a ** $b; // outputs 1000
?>
Raise the number 2
to the 10
th power.
Display the result on the screen.