W3Schools.com

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
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$3.98 Unlimited Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Best Website Templates Top CSS Templates
CREATE HTML Websites
EASY WEBSITE BUILDER
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE