The tan()
function in PHP returns the tangent of a number in radians.
The following illustration shows the mathematical representation of the tan()
function.
This
tan()
function only works for right-angled triangles.
To convert degrees to radians, use the following formula:
radians = degrees * ( M_PI / 180.0 )
<?php#Positive number in radiansecho("tan(2.3): ");echo (tan(2.3));?><?php#Negative number in radiansecho("tan(-2.3): ");echo (tan(-2.3));?><?php#converting the degrees angle into radians and then applying tan()#degrees = 45echo("tan(45 * (M_PI / (180))): ");echo (tan(45 * (M_PI / (180))));?>
Free Resources