PHP hypot() Function

Definition

The hypot() function calculates the hypotenuse of a right-angle triangle.

Syntax

PHP hypot() Function has the following syntax.

hypot(x,y);

Parameter

ParameterIsRequired Description
xRequired.Length of first side
yRequired.Length of second side

Return

Item Description
Return Value The length of the hypotenuse
Return Type Float

Note

This function is equivalent to sqrt(x*x + y*y).

Example

Calculate the hypotenuse of different right-angle triangles:


<?php//from www  . j ava 2 s  .  co m
echo hypot(3,4) . "\n";
echo hypot(4,6) . "\n";
echo hypot(1,3) . "\n";
echo sqrt(3*3+4*4);
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions