PHP sqrt() function

Definition and usage

The sqrt() function returns the square root of a number.

Syntax

sqrt(x)
Parameter Description
x Required. A number.

Description

Returns x The square root of

Tips and comments

Note:If the parameter x If the parameter is negative, the sqrt() function returns -1.#IND.

Example

In this example, we will return the square root of different numbers:

<?php
echo(sqrt(0));
echo(sqrt(1));
echo(sqrt(9));
echo(sqrt(0.64));
echo(sqrt(-9));
?>

Output:

0
1
3
0.8
-1.#IND