PHP tan() Function

In this chapter you will learn:

  1. Definition for PHP tan() Function
  2. Syntax for PHP tan() Function
  3. Parameter for PHP tan() Function
  4. Return for PHP tan() Function
  5. Example - Return the tangent of different numbers

Definition

Calculates the tangent value of the number provided as its only parameter.

Syntax

PHP tan() Function has the following syntax.

float tan ( float num )

Parameter

ParameterDescription
numberRequired. Specifies a value in radians

The parameter should be passed as radians. We should use deg2rad() to convert degrees to radians.

Return

Item Value
Return ValueThe tangent of number
Return TypeFloat

Example

Return the tangent of different numbers


<?php/*j  a v  a2  s.  co  m*/

$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));
?>

The code above generates the following result.

Next chapter...

What you will learn in the next chapter:

  1. Definition for PHP tanh() Function
  2. Syntax for PHP tanh() Function
  3. Parameter for PHP tanh() Function
  4. Return for PHP tanh() Function
  5. Example - Return the hyperbolic tangent of different numbers