Home  >  Article  >  Backend Development  >  How to use php sqrt function?

How to use php sqrt function?

藏色散人
藏色散人Original
2019-05-29 15:07:193264browse

php The sqrt function is used to return the square root of a number. Its syntax is sqrt(x). The parameter x is required and refers to a number.

How to use php sqrt function?

#How to use php sqrt function?

Definition and usage

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

Syntax

sqrt(x)

Parameters

x Required. a number.

Description

Returns the square root of x.

Tips and Notes

Note: If the parameter x is a negative number, the sqrt() function returns -1.#IND.

Example

In this example we will return the square roots of distinct numbers:

<?php
echo(sqrt(0));
echo(sqrt(1));
echo(sqrt(9));
echo(sqrt(0.64));
echo(sqrt(-9));
?>

Output:

0
1
3
0.8
-1.#IND

The above is the detailed content of How to use php sqrt function?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn