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


PHP tan()用法及代碼示例


tan() 函數是 PHP 的三角數學函數,用於計算三角問題。它返回一個數字的正切。

用法:

tan(number);
參數 描述 必需/可選
number 以弧度指定值 required

例子1

<?php
$num=M_PI_4;
echo "Your number is M_PI_4 = ".$num;
echo "<br>"."By using 'tan()' function your number is:".(tan($num));
?>

輸出:

Your number is M_PI_4 = 0.78539816339745
By using 'tan()' function your number is:1

例子2

<?php
$num=(0.50);
echo "Your number is = ".$num;
echo "<br>"."By using 'tan()' function your number is:".(tan($num));
?>

輸出:

Your number is = 0.5
By using 'tan()' function your number is:0.54630248984379

例子3

<?php
$num=(-0.50);
echo "Your number is = ".$num;
echo "<br>"."By using 'tan()' function your number is:".(tan($num));
?>

輸出:

Your number is = -0.5
By using 'tan()' function your number is:-0.54630248984379

示例 4

<?php
$num=(5);
echo "Your number is = ".$num;
echo "<br>"."By using 'tan()' function your number is:".(tan($num));
?>

輸出:

Passing number is = 5
By using 'tan()' function your number is:-3.3805150062466

例 5

<?php
$num=(10);
echo "Passing number is = ".$num;
echo "<br>"."By using 'tan()' function your number is:".(tan($num));
?>

輸出:

Passing number is = 10
By using 'tan()' function your number is:0.64836082745909

例 6

<?php
$num=(-5);
echo "Passing number is = ".$num;
echo "<br>"."By using 'tan()' function your number is:".(tan($num));
?>

輸出:

Passing number is = -5
By using 'tan()' function your number is:3.3805150062466

例 7

<?php
$num=(0.50);
echo "Passing number is (0.50)";
echo "<br>"."By using 'tan()' function your number is:".(tan($num));
?>

輸出:

Passing number is:0.5
By using 'tan()' function your number is:0.54630248984379

例 8

<?php
$num=(3*pi()/2);
echo "Passing number is:3*pi()/2";
echo "<br>"."By using 'tan()' function your number is:".(tan($num));
?>

輸出:

Passing number is:3*pi()/2
By using 'tan()' function your number is:5.4437464510651E+15






相關用法


注:本文由純淨天空篩選整理自 PHP tan() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。