sqrt() function calculates the square root of a number. It takes a single parameter in the form of a number and returns the square root of that number.
$result = sqrt($value)
$valueis the number whose square root is being calculated.
$resultis the resultant square root value.
Note: If a negative number is passed as an argument, the function will return
NAN. Therefore, only nonnegative numbers should be passed to avoid unexpected results and maintain accurate calculations.
The following example demonstrates the usage of
sqrt() function to find the square root of
<?php$value = 25;$squareRoot = sqrt($value);echo "The square root of $value is: $squareRoot";?>
The example will result in the following output:
The square root of 25 is: 5