Backend Development 2 min read

PHP hypot() Function – Calculate the Length of the Hypotenuse

The article explains PHP’s hypot() function, which computes the hypotenuse length of a right‑angled triangle given side lengths x and y (or the distance from the origin), details its parameters and return value, and provides sample code with expected output.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
PHP hypot() Function – Calculate the Length of the Hypotenuse

hypot() calculates the length of the hypotenuse of a right‑angled triangle based on the lengths of the two legs $x and $y , equivalent to sqrt($x*$x + $y*$y) .

Parameters

$x – length of the first side.

$y – length of the second side.

Return value

Returns the computed hypotenuse length as a float.

Example

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

Output

5
7.211102550928
3.1622776601684
5
backendPHPmathfunctionExamplehypot
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.