当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


PHP math acos()用法及代码示例


acos() 函数是用于计算三角问题的有用的预定义 PHP 函数。它用于以弧度为单位查找数字的反余弦值。

注意:acos(-1) 返回 Pi 的值。

用法:

acos(number);
参数 描述 必需/可选
Number 在 -1 到 1 范围内指定一个数字。 Required

示例 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






相关用法


注:本文由纯净天空筛选整理自 PHP math acos() function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。