PHP sqrt() Function

Definition

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

Syntax

PHP sqrt() Function has the following syntax.

float sqrt ( float num )

Parameter

ParameterDescription
numberRequired. Specifies a number

Return

Item Value
Return ValueThe square root of number, or NAN for negative numbers
Return TypeFloat

Example

Return the square root of different numbers:


<?php//from ww w . j  ava  2 s  . c  o m
print sqrt(25); 
print "\n";
print sqrt(26); 
print "\n";
echo(sqrt(0) . "\n");
echo(sqrt(1) . "\n");
echo(sqrt(9) . "\n");
echo(sqrt(0.64) . "\n");
echo(sqrt(-9));
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions