當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。