hypot()
Published Jul 20, 2023
Contribute to Docs
The hypot()
function returns the length of the hypotenuse of a 90-degree or “right-angle” triangle.
Syntax
$hypotenuse = hypot($length1, $length2);
Given a right-angle triangle with sides $length1
and $length2
, the function returns the result of the following formula:
The function accepts two float
inputs and returns a value of type float
.
Example
This example calculates the hypotenuse of a right-angle triangle with sides of length 6
and 8
.
<?php$hypotenuse = hypot(6, 8);echo $hypotenuse;?>
This example results in the following output:
10
Codebyte Example
This example returns the hypotenuse for a 90-degree triangle with sides of length 12
and 16
:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.