Square Root Function in PHP



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

Syntax

sqrt(num)

Parameters

  • num − The number for which you want to find the square root

Return

The sqrt() function Returns the square root of the specified number.

Example

 Live Demo

<?php
   echo(sqrt(16));
?>

Output

4

Example

Let us see another example −

 Live Demo

<?php
   echo(sqrt(0.25) . "<br>");
?>

Output

0.5<br>

Example

Let us see another example −

 Live Demo

<?php
   echo(sqrt(-144));
?>

Output

NAN
Updated on: 2019-12-27T10:00:14+05:30

77 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements