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( )用法及代碼示例
- PHP sinh( )用法及代碼示例
- PHP simplexml_load_file()用法及代碼示例
- PHP simplexml_load_string()用法及代碼示例
- PHP simplexml_import_dom()用法及代碼示例
- PHP sizeof()用法及代碼示例
- PHP similar_text()用法及代碼示例
- PHP string rtrim()用法及代碼示例
- PHP strsrt()用法及代碼示例
- PHP strnatcasecmp()用法及代碼示例
- PHP string printf()用法及代碼示例
- PHP string ord()用法及代碼示例
- PHP string join()用法及代碼示例
- PHP Spreadsheet_Excel_Writer setAlign()用法及代碼示例
- PHP strtolower()用法及代碼示例
- PHP Spreadsheet_Excel_Writer setScript()用法及代碼示例
- PHP str_split()用法及代碼示例
- PHP stream_get_filters()用法及代碼示例
- PHP Spreadsheet_Excel_Writer setOutLine()用法及代碼示例
- PHP strchr()用法及代碼示例
注:本文由純淨天空篩選整理自 PHP sin() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。