take the sine of a number in php

To take the sine of a number in PHP, you can use the built-in sin() function from the math module.

Here's an example:

main.php
$num = 45;
$sin = sin(deg2rad($num));
echo "The sine of $num is: $sin";
72 chars
4 lines

In this example, we first set the value of the variable $num to the number we want to take the sine of (45 in this case).

Next, we use the sin() function to calculate the sine of the angle (in radians) by passing the deg2rad() of the angle as argument.

Finally, we print out the result using echo statement which will output "The sine of 45 is: 0.70710678118655".

Note that the deg2rad() function is used to convert degrees to radians as the sin() function works with radians.

gistlibby LogSnag