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.
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
5Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.