fonction hypot PHP ()
Exemples
Calculer la longueur différente de l'hypoténuse d'un triangle rectangle:
<?php
echo hypot(3,4) . "<br>";
echo hypot(4,6) . "<br>";
echo hypot(1,3) . "<br>";
echo sqrt(3*3+4*4);
?>
echo hypot(3,4) . "<br>";
echo hypot(4,6) . "<br>";
echo hypot(1,3) . "<br>";
echo sqrt(3*3+4*4);
?>
Exécution instance »
Définition et utilisation
hypot () calcule la longueur de l'hypoténuse d'un triangle rectangle.
Astuce: Cette fonction est équivalente à sqrt (x * x + y * y).
grammaire
hypot( x,y );
参数 | 描述 |
---|---|
x | 必需。规定第一条直角边的长度。 |
y | 必需。规定第二条直角边的长度。 |
détails techniques
Retours: | Longueur de l'hypoténuse. |
---|---|
Type de retour: | flotteur |
PHP version: | 4.1+ |
PHP Math Reference