PHP math acos()函数
The acos()函数是一个有用的预定义PHP函数,用于计算三角学问题。它用于以弧度形式找到一个数的反余弦。
注意:acos(-1)返回Pi的值。
语法
acos(number);
参数 | 描述 | 必需/可选 |
---|---|---|
数字 | 指定一个范围在-1到1的数字。 | 必需 |
示例1
<?php
num=0;
echo "Your number is :".num;
echo "<br>"."By using 'acos()' function your number is :".(acos($num));
?>
输出结果:
Your number is :0
By using 'acos()' function your number is :1.5707963267949
示例2
<?php
num=1;
echo "Your number is :".num;
echo "<br>"."By using 'acos()' function your number is :".(acos($num));
?>
输出:
Your number is :1
By using 'acos()' function your number is :0
示例3
<?php
num=2;
echo "Your number is :".num;
echo "<br>"."By using 'acos()' function your number is :".(acos($num));
echo "<br>"." Note : Your number is outside the range [-1,1]";
?>
输出:
Your number is :2
By using 'acos()' function your number is :NAN
Note : Your number is outside the range [-1,1]
示例4
<?php
num=(0.64);
echo "Your number is :".num;
echo "<br>"."By using 'acos()' function your number is :".(acos($num));
?>
输出:
Your number is :0.64
By using 'acos()' function your number is :0.87629806116834
示例5
<?php
num=(-0.4);
echo "Your number is :".num;
echo "<br>"."By using 'acos()' function your number is :".(acos($num));
?>
输出:
Your number is :-0.4
By using 'acos()' function your number is :1.9823131728624
示例6
<?php
num=(-1);
echo "Your number is :".num;
echo "<br>"."By using 'acos()' function your number is :".(acos($num));
?>
输出:
Your number is :-1
By using 'acos()' function your number is :3.1415926535898