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
<?php
echo hypot(3,4);
echo "<br>";
echo hypot(4,6);
echo "<br>";
echo hypot(1,3);
echo "<br>";
echo sqrt(3*3+4*4);
?>Output
5
7.211102550928
3.1622776601684
5Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Laravel 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.
