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


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。