Latest web development tutorials

PHP hypot () function

PHP Math Reference PHP Math Reference

Examples

Calculate different length of the hypotenuse of a right triangle:

<?php
echo hypot(3,4) . "<br>";
echo hypot(4,6) . "<br>";
echo hypot(1,3) . "<br>";
echo sqrt(3*3+4*4);
?>

Running instance »

Definition and Usage

hypot () function calculates the length of the hypotenuse of a right triangle.

Tip: This function is equivalent to sqrt (x * x + y * y).


grammar

hypot( x,y );

参数 描述
x 必需。规定第一条直角边的长度。
y 必需。规定第二条直角边的长度。

technical details

return value: Length of the hypotenuse.
Return type: Float
PHP version: 4.1+


PHP Math Reference PHP Math Reference