# Raise a Number to the Power of Another in PHP

You might need to raise a number to the power of another in a PHP script, for example $3^5=3×3×3×3×3$ (sometimes written 3^5), or in general $x^n$. This may also be used with negative powers where $x^{−n}=\frac{1}{x^n}$. Of course, you’d probably want to do this for more complicated examples!

PHP has a function built in to do this: $x^n$ = pow(x,n).

## Examples of ‘Power Of’

Here are some examples, which raise a number to the power of another and display the output. In the examples, <br /> inserts a line break to display the results neatly.

And here is the output of this example code:

×

## Subscribe

The latest posts sent straight to your inbox.