Home  >  Article  >  Backend Development  >  A very niche php method: hypot

A very niche php method: hypot

藏色散人
藏色散人forward
2021-04-26 17:08:004876browse

This article will introduce you to a niche php method: hypot. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

A niche php method: hypot

How do we generally calculate the length of the hypotenuse of a right triangle?

$a = 3;
$b = 4;
echo sqrt($a * $a + $b * $b);
//或者
echo sqrt(pow($a,2) + pow($b,2));

No, no, no,

php provides us with the native method: hypot()

echo hypot(3,4);//5
echo hypot(6,8);//10

The above is the detailed content of A very niche php method: hypot. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete