pTutorial

New way to learn PHP function

PHP sqrt() Function

Syntax

sqrt($number);

Parameter Description
Number Number can be integer or float

Definition

It Returns the square root of the any number.

Usage

Sqrt function is used to calculate the square root of number, number can be integer of float.

Example of sqrt function

<?php

echo sqrt(16);

?>

In above example 16 is an integer type number that has passed into the sqrt function as an argument and it will calculate the square root of the number 16.

More example of sqrt function

<?php

$a = 144;

var_dump($a);

echo sqrt($a);

?>

In above example $a is a variable that has held integer value as previous example but in this case first it has to stored on a variable and then passed it to the sqrt function.

You can check data type of any variable or value by using var_dump function as i used. And at last the variable $a has passed into the sqrt function.

Example

<form method="post">
Enter any number <br/>
<input type="text" name="uk"><br/>
<input type="submit" name="sub">
</form>



<?php
if(isset($_POST['sub']))
{
	$uk=$_POST['uk'];
	echo "Result = " . sqrt($uk);
}



?>

Output

Enter any number for calculate square root

You can enter any number integer as well as float for calculating square root.

QUOTES OF THE DAY

Goal is tired by fire, brave men by adversity.

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER