# Calculate Square Roots in PHP

To find the nth root of a number in PHP, we can use the pow(base, power) function, for example the cube root of 27 is equal to 27 raised to the power of 1/3, $\sqrt[3]{27} = 27^{1/3}$, since $3^3=27$. In general the nth root of x, $\sqrt[n]{x}=x^{1/n}$.

To calculate the square root of a number, we can also use the sqrt(number) function.

## Example

Some example code showing how to calculate roots in PHP is below:

The output from this example is as follows:

×

## Subscribe

The latest posts sent straight to your inbox.