PHP sqrt( ) Function (original) (raw)

Last Updated : 22 Jun, 2023

Many times it happens that while solving mathematical expressions we require to calculate the square root of a number.
To solve this issue like other programming language PHP provides us with a built-in function sqrt() which can be used to calculate the square root of a number. The sqrt() function in PHP is used to calculate the square root of a number.
We already have discussed about sqrt() function in brief in the article PHP | Math functions. In this article we will learn about the sqrt() function in details.

Syntax:

float sqrt(value)

Parameters: This function accepts a single parameter $value. It is the number whose square root you want to know.

Return Value: It returns a floating-point value which is the square root of the argument $value passed to it.

Examples:

Input : sqrt(25) Output : 5

Input : sqrt(-25) Output : NaN

Input : sqrt(0.09) Output :0.3

Input : sqrt(0) Output : 0

Below programs illustrate the working of sqrt() in PHP:

`

Output:

5

`

Output:

NaN

`

Output:

0.3

`

Output:

0

Important Points To Note:

Reference:
https://www.php.net/manual/en/function.sqrt.php