PHP sin() Function
The PHP sin() function returns trigonometric sine of an angle (angle should be in radians). In special cases it returns the following:
- If the argument is NAN or an infinity, then the result is NAN.
In the graph below, sin(x) vs x is plotted.
Syntax
sin(number)
Parameters
number |
Required. Specify the angle in radian. |
Return Value
Returns the trigonometric sine of an angle.
Example:
In the example below, sin() function is used to find out the trigonometric sine of an angle.
<?php echo "sin(pi()/6) = ".sin(pi()/6)."\n"; echo "sin(pi()/4) = ".sin(pi()/4)."\n"; echo "sin(pi()/3) = ".sin(pi()/3)."\n"; echo "sin(deg2rad(45)) = ".sin(deg2rad(45))."\n"; echo "sin(M_PI/2) = ".sin(M_PI/2)."\n"; echo "sin(M_PI_4) = ".sin(M_PI_4)."\n"; echo "sin(NAN) = ".sin(NAN)."\n"; echo "sin(INF) = ".sin(INF)."\n"; ?>
The output of the above code will be:
sin(pi()/6) = 0.5 sin(pi()/4) = 0.70710678118655 sin(pi()/3) = 0.86602540378444 sin(deg2rad(45)) = 0.70710678118655 sin(M_PI/2) = 1 sin(M_PI_4) = 0.70710678118655 sin(NAN) = NAN sin(INF) = NAN
❮ PHP Math Reference