PHP deg2rad() Function
In this chapter you will learn:
- Definition for PHP deg2rad() Function
- Syntax for PHP deg2rad() Function
- Parameter for PHP deg2rad() Function
- Return for PHP deg2rad() Function
- Note for PHP deg2rad() Function
- Example - converts degrees to radians
Definition
The deg2rad()
function converts degrees to radians.
Syntax
PHP deg2rad() Function has the following format.
float deg2rad ( float num )
Parameter
Parameter | Is Required | Description |
---|---|---|
num | Required. | Degree to convert |
Return
Item | Description |
---|---|
Return Value | The radian equivalent of number |
Return Type | Float |
Note
To convert a radian value to a degree value, look at the rad2deg() function.
Example
Radians are calculated as being $degrees multiplied by the mathematical constant pi, then divided by 180.
/*from j a v a 2 s .c om*/
<?php
echo deg2rad("45") . "\n";
echo deg2rad("90") . "\n";
echo deg2rad("360"). "\n";
$deg = 180;
$rad = deg2rad($deg);
echo "$deg degrees is equal to $rad radians.\n";
$sin1 = sin(deg2rad(80));
print $sin1;
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP exp() Function
- Syntax for PHP exp() Function
- Parameter for PHP exp() Function
- Return for PHP exp() Function
- Example - Return 'e' raised to the power of different numbers
Home » PHP Tutorial » PHP Math Functions