take the tangent of a number in php

You can use the tan() function in PHP's math library to find the tangent of a given number. Here's an example usage:

main.php
$num = 45; // the number
$tan = tan($num); // find its tangent
echo "The tangent of $num is $tan"; // print the result
119 chars
4 lines

This will output:

main.php
The tangent of 45 is 1.6197751905439
37 chars
2 lines

Note that the tan() function expects its input to be in radians, so if you're working with degrees, you'll need to convert the angle first. For example, to find the tangent of 45 degrees:

main.php
$num = 45; // the number in degrees
$rad = deg2rad($num); // convert to radians
$tan = tan($rad); // find the tangent
echo "The tangent of $num degrees is $tan"; // print the result
182 chars
5 lines

This will output:

main.php
The tangent of 45 degrees is 1
31 chars
2 lines

gistlibby LogSnag