asin() accepts a value from -1 through 1 and returns the corresponding angle in radians.
$angle = asin(0.5);
echo rad2deg($angle); // approximately 30
The examples below build from the basic call to practical variations and edge cases.
<?Php
echo asin(0); // Output is 0
echo "<br>";
echo asin(1); // Output 1.5707963267949
echo "<br>";
echo asin(-1); // Output is -1.5707963267949
echo "<br>";
echo asin(4); // Output is NAN
?>
Syntax
asin(float $num): float;
The argument is a sine value, not an angle. Valid real inputs are from -1 through 1; values outside this range return NAN. The return value is an angle in radians.
$sine = 0.5;
$angleRadians = asin($sine);
echo rad2deg($angleRadians); // 30
The *asin()* function can also be used to find the inverse sine of a negative value:
$value = -0.5;
$result = asin($value);
echo "The arcsin of $value is: " . $result;
// Outputs: The arcsin of -0.5 is: -0.5235987755983
To convert the result from radians to degrees:
$value = 0.5;
$radians = asin($value);
$degrees = rad2deg($radians);
echo "The arcsin of $value in degrees is: " . $degrees;
// Outputs: The arcsin of 0.5 in degrees is: 30
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.