PHP sqrt() Function
Example
Return the square root of different numbers:
<?php
echo(sqrt(0) . "<br>");
echo(sqrt(1) . "<br>");
echo(sqrt(9) . "<br>");
echo(sqrt(0.64) . "<br>");
echo(sqrt(-9));
?>
Try it Yourself »
Definition and Usage
The sqrt() function returns the square root of a number.
Syntax
sqrt(number);
Parameter Values
Parameter | Description |
---|---|
number | Required. Specifies a number |
Technical Details
Return Value: | The square root of number, or NAN for negative numbers |
---|---|
Return Type: | Float |
PHP Version: | 4+ |
❮ PHP Math Reference