Search w3schools.com:

SHARE THIS PAGE

PHP sqrt() Function


PHP Math Reference Complete PHP Math Reference

Definition and Usage

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

Syntax

sqrt(x)

Parameter Description
x Required. A number


Tips and Notes

Note: The sqrt() function will return -1.#IND if the parameter x is a negative number.


Example

In this example we will get 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))
?>

The output of the code above will be:

0
1
3
0.8
-1.#IND


PHP Math Reference Complete PHP Math Reference

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]