In this tutorial, you shall learn about Arithmetic Exponentiation Operator in PHP, its syntax, and how to use this operator in PHP programs, with examples.

PHP Exponentiation

PHP Arithmetic Exponentiation Operator takes two numbers as operands and returns the result of the first number raised to the power of second number.

Symbol

** symbol is used for Exponentiation Operator.

Syntax

The syntax for Exponentiation Operator is

</>
Copy
operand_1 ** operand_2

The operands could be of any numeric datatype, integer or float.

Examples

1. Integer raised to the Power (Exponent) of Integer

In the following example, we take integer values in $x and $y, and find $x raised to the power $y.

PHP Program

</>
Copy
<?php
  $x = 5;
  $y = 4;

  $output = $x ** $y;

  echo "x = $x" . "<br>";
  echo "y = $y" . "<br>";
  echo "x ** y = $output";
?>

Output