PHP hypot() Function

In this chapter you will learn:

  1. Definition for PHP hypot() Function
  2. Syntax for PHP hypot() Function
  3. Parameter for PHP hypot() Function
  4. Return for PHP hypot() Function
  5. Note for PHP hypot() Function
  6. Example - Calculate the hypotenuse of different right-angle triangles

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   ja va 2  s. c  om*/
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.

Next chapter...

What you will learn in the next chapter:

  1. Definition for PHP is_finite() Function
  2. Syntax for PHP is_finite() Function
  3. Parameter for PHP is_finite() Function
  4. Return for PHP is_finite() Function
  5. Example - Check whether a value is finite or not