PHP sqrt()函数
sqrt()是一个数学函数,用于计算任意数的平方根。
语法
float sqrt(value)
| Parameter | Description | Required /Optional | 
|---|---|---|
| number | Specifies a number | Required | 

示例1
<?php
num=625;
echo "Your number is :num".'<br>';
echo "By using sqrt function Your number is : ".sqrt ($num);
?>
输出:
Your number is : 625
By Using sqrt function Your number is : 25
示例2
<?php
num=(-9);
echo "Your number is :num".'<br>';
echo "By using sqrt function Your number is : ".sqrt ($num);
?>
输出:
Your number is : -9
By using sqrt function Your number is : NAN
注意:对于负数,参数的平方根或特殊值NAN。
示例3
<?php
num=(0.09);
echo "Your number is :num".'<br>';
echo "By using sqrt function Your number is : ".sqrt ($num);
?>
输出:
Your number is : 0.09
By using sqrt function Your number is : 0.3
示例4
<?php
a=3;  // One sideb=4;  // One side
h=sqrt(pow(a,2)+pow(b,2));
echo "Your number is :a and b".'<br>';
echo "By using sqrt function (pow(a,2)+pow(b,2)) Your number is : ".h;
?>
输出:
Your number is : 3 and 4
By using sqrt function (pow(3,2)+pow(4,2)) Your number is : 5
 极客笔记
极客笔记