w3resource

PHP: hypot() function

Description

The hypot() function is used to calculate the length of the hypotenuse of a right-angle triangle.

Version:

(PHP 4 and above)

Syntax:

hypot (nx,ny )

Parameter:

Name Description Required /
Optional
Type
nx Length of first side Required Float
ny Length of second side Required Float

Return value:

The length of the hypotenuse.

Value Type: Float.

Example:


<?php
echo hypot(3,4) . "<br />";
echo hypot(3,5) . "<br />";
echo hypot(4,7) . "<br />";
echo hypot(2,6);
?> 

Output:

5
5.83095189485
8.0622577483
6.32455532034 

View the example in the browser

See also

PHP Function Reference

Previous: hexdec
Next: is_finite



Follow us on Facebook and Twitter for latest update.