PHP sqrt() - Math Functions

What is sqrt Function?

Explanation

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

Syntax:


sqrt(x)

In the above syntax "x" is the number for which the square root is to be calculated.

Example :


<?php
echo(sqrt(0)) ."</br>";
echo(sqrt(1)) ."</br>";
echo(sqrt(4)) ."</br>";
echo(sqrt(0.49)) ."</br>";
echo(sqrt(-4)) ."</br>";
?>
Result :

0
1
2
0.7
NAN

In the above example the square root for a negative number returns "NAN".

PHP Topics


Ask Questions

Ask Question