PHP sqrt()函数

PHP sqrt()函数

sqrt()是一个数学函数,用于计算任意数的平方根。

语法

float sqrt(value)
Parameter Description Required /Optional
number Specifies a number Required

PHP sqrt()函数

示例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

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程