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


PHP sin()用法及代码示例


PHP 提供了各种重要的三角函数。 sin() 就是其中之一。它用于计算三角问题并返回 arg 参数的正弦值。 arg 参数以弧度为单位。

用法:

float sin ( float $arg )
参数 描述 必需/可选
number 以弧度指定值 Required

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






相关用法


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