PHP hypot() 函数
hypot() 函数是PHP的数学函数。它用于计算直角三角形的斜边长度。它返回直角三角形的斜边长度,该三角形的两边长度分别为 x 和 y。
语法
float hypot ( float x , floaty )
hypot() 返回一个直角三角形的斜边长度,该三角形的两条边长分别为x和y。
参数 | 描述 | 必填/选填 |
---|---|---|
x | 指定第一边的长度 | 必填 |
y | 指定第二边的长度 | 必填 |
示例1
<?php
echo "Your Number is (3,4)";
echo "<br>"."By using 'hypot()' Function your Value is ".hypot(3,4);
?>
输出:
Your Number is (3,4)
By using 'hypot()' Function your Value is 5
示例2
<?php
echo "Your Number is (4,6)";
echo "<br>"."By using 'hypot()' Function your Value is ".hypot(4,6);
?>
输出:
Your Number is (4,6)
By using 'hypot()' Function your Value is 7.211102550928
示例3
<?php
echo "Your Number is (1,3)";
echo "<br>"."By using 'hypot()' Function your Value is ".hypot(1,3);
?>
输出:
Your Number is (1,3)
By using 'hypot()' Function your Value is 3.1622776601684
示例4
<?php
echo "Your Number is (3*3+4*4) ";
echo "<br>"."By using 'hypot()' Function your Value is ".sqrt(3*3+4*4);
?>
输出:
Your Number is (3*3+4*4)
By using 'hypot()' Function your Value is 5