Home > Backend Development > PHP Problem > How to use php sqrt function?

How to use php sqrt function?

藏色散人
Release: 2023-02-22 22:02:01
Original
3391 people have browsed it

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)
Copy after login

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));
?>
Copy after login

Output:

0
1
3
0.8
-1.#IND
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template