w3resource

PHP: tan() function

Description

The tan() function returns the tangent of a number.

Version:

(PHP 4 and above)

Syntax:

tan(num)

Parameter:

Name Description Required /
Optional
Type
num A number. Required Float

Return value:

The tangent of num.

Value Type: Float

Pictorial Presentation

php-math-tan()

Example:

<?php
$val1= 0;
$val2=4;
$val3=-4;
$val4= M_PI_4;
$ztan1=tan($val1);
$ztan2=tan($val2);
$ztan3=tan($val3);
$ztan4=cos($val4);
echo "Tangent of $val1 is $ztan1<br />";
echo "Tangent of $val2 is $ztan2<br />";
echo "Tangent of $val3 is $ztan3<br />";
echo "Tangent of $val4 is $ztan4<br />";
?>

Output:

Tangent of 0 is 0
Tangent of 4 is 1.1578212823496
Tangent of -4 is   -1.1578212823496
Tangent of  M_PI_4 is 

View the example in the browser

See also

PHP Function Reference

Previous: srand
Next: tanh



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/php/function-reference/tan.php