PHP sin()函数
PHP提供了各种重要的三角函数。sin()是其中之一。它用于计算三角问题,并返回参数 arg 的正弦值。参数 arg 是以弧度表示的。
语法
float sin ( float $arg )
参数 | 描述 | 必需/可选 |
---|---|---|
number | 指定以弧度为单位的值 | 必需 |
示例1
<?php
echo "Your argument value is : 3*pi()/2";
echo "<br>"."By using 'sin()' function your number is :".(sin(3*pi()/2));
?>
输出:
Your argument value is : 3*pi()/2
By using 'sin()' function your number is :-1
示例2
<?php
num=3;
echo "Your number is :".num;
echo "<br>"."By using 'sin()' function your number is :".(sin($num));
?>
输出:
Your number is :3
By using 'sin()' function your number is :0.14112000805987
示例3
<?php
num=(-3);
echo "Your number is :".num;
echo "<br>"."By using 'sin()' function your number is :".(sin($num));
?>
输出:
Your number is :-3
By using 'sin()' function your number is :-0.14112000805987
示例4
<?php
num=0;
echo "Your number is :".num;
echo "<br>"."By using 'sin()' function your number is :".(sin($num));
?>
输出:
Your number is :0
By using 'sin()' function your number is :0
示例5
<?php
num=(M_PI) ;
echo "Your number is (M_PI) : ".num;
echo "<br>"."By using 'sin()' function your number is :".(sin($num));
?>
输出:
Your number is (M_PI) : 3.1415926535898
By using 'sin()' function your number is :1.2246467991474E-16
示例6
<?php
num=(M_PI_2) ;
echo "Your number is (M_PI_2) : ".num;
echo "<br>"."By using 'sin()' function your number is :".(sin($num));
?>
输出:
Your number is (M_PI_2) : 1.5707963267949
By using 'sin()' function your number is :1