定义

tan()函数计算指定弧度的正切值。

 

语法

PHP tan()函数具有以下语法。

float tan ( float num )

 

参数

参数 描述
num 需要。指定以弧度表示的值

该参数应以弧度形式传递。我们应该使用deg2rad()将度转换为弧度。

 

返回值

项目
返回值 弧度的正切
返回类型 浮点型

 

实例

返回不同数字的正切

<?php
/*
http://www.manongjc.com/article/1748.html
作者:码农教程
*/

$tan1 = tan(10); 
print($tan1);
print \"\\n\";
$tan2 = tan(deg2rad(80));
print($tan2);
print \"\\n\";

echo(tan(M_PI_4) . \"\\n\");
echo(tan(0.50) . \"\\n\");
echo(tan(-0.50) . \"\\n\");
echo(tan(5) . \"\\n\");
echo(tan(1) . \"\\n\");
echo(tan(-5) . \"\\n\");
echo(tan(-1));
?>

上面的代码生成以下结果:

0.64836082745909
5.6712818196177
1
0.54630248984379
-0.54630248984379
-3.3805150062466
1.5574077246549
3.3805150062466
-1.5574077246549
收藏 打印