Home >>PHP Math Functions >PHP hypot() Function
PHP hypot() function is used to return the square root of sum of square of given input values passed as arguments. It finds the hypotenuse which is the longest side of a right angled triangle. It is equivalent to the formula “sqrt(x*x + y*y)”, where x and y are the two sides of the right angled triangle having an angle of 90° between them.
Syntax:
hypot($x,$y);
Parameter | Description |
---|---|
x | This is a required parameter. This parameter defines the length of first side. |
y | This is a required parameter. This parameter defines the length of second side. |
Here is an example of hypot() function in PHP:
<html> <body> <?php echo hypot(5,12)."<br>"; echo sqrt(5*5+12*12)."<br>"; echo hypot(8,15)."<br>"; echo sqrt(8*8+15*15)."<br>"; ?> </body> </html>
Here is an another example of hypot() function in PHP:
<html> <body> <?php echo hypot(1,5)."<br>"; echo hypot(4,12)."<br>"; echo hypot(7,33)."<br>"; echo hypot(12,54)."<br>"; ?> </body> </html>