PHP deg2rad() Function

Definition

The deg2rad() function converts degrees to radians.

Syntax

PHP deg2rad() Function has the following format.

float deg2rad ( float num )

Parameter

Parameter Is RequiredDescription
num Required. Degree to convert

Return

Item Description
Return ValueThe radian equivalent of number
Return TypeFloat

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  w  ww  .ja  v  a2s .c  o  m
<?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.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions