Calculate the hypotenuse of different right-angle triangles:
<?php
echo hypot(3,4) . "<br>";
echo hypot(4,6) . "<br>";
echo hypot(1,3) . "<br>";
echo sqrt(3*3+4*4);
?>
Try it Yourself »
The hypot() function calculates the hypotenuse of a right-angle triangle.
Tip: This function is equivalent to sqrt(x*x + y*y).
hypot(
x,y);
Parameter | Description |
---|---|
x | Required. Specifies the length of first side |
y | Required. Specifies the length of second side |
Return Value: | The length of the hypotenuse |
---|---|
Return Type: | Float |
PHP Version: | 4.1+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!