The sqrt()
function gets the square root of a number.
PHP sqrt() Function has the following syntax.
float sqrt ( float num )
Parameter | Description |
---|---|
number | Required. Specifies a number |
Item | Value |
---|---|
Return Value | The square root of number, or NAN for negative numbers |
Return Type | Float |
Return the square root of different numbers:
<?php// w w w . j ava 2 s.c om
print sqrt(25);
print "\n";
print sqrt(26);
print "\n";
echo(sqrt(0) . "\n");
echo(sqrt(1) . "\n");
echo(sqrt(9) . "\n");
echo(sqrt(0.64) . "\n");
echo(sqrt(-9));
?>
The code above generates the following result.