deg2rad() function in PHP

The deg2rad() function converts degree values to their radian equivalents. Radians are the standard unit of angular measurement used in many mathematical calculations, while degrees are more commonly used in everyday applications.

Syntax

deg2rad(number)

Parameters

  • number − The degree value to be converted to radians. Accepts integer or float values.

Return Value

Returns a float representing the radian equivalent of the specified degree value.

Example 1: Basic Conversion

Here's how to convert a single degree value to radians −

<?php
    $degVal = 360;
    $radVal = deg2rad($degVal);
    echo "$degVal degrees converted to $radVal radians!";
?>
360 degrees converted to 6.2831853071796 radians!

Example 2: Multiple Conversions

Converting common angle measurements −

<?php
    echo "45 degrees = " . deg2rad(45) . " radians<br>";
    echo "90 degrees = " . deg2rad(90) . " radians<br>";
    echo "180 degrees = " . deg2rad(180) . " radians<br>";
    echo "270 degrees = " . deg2rad(270) . " radians<br>";
    echo "360 degrees = " . deg2rad(360) . " radians";
?>
45 degrees = 0.78539816339745 radians
90 degrees = 1.5707963267949 radians
180 degrees = 3.1415926535898 radians
270 degrees = 4.7123889803847 radians
360 degrees = 6.2831853071796 radians

Key Points

  • The conversion formula is: radians = degrees × (?/180)
  • 180 degrees equals ? radians (approximately 3.14159)
  • 360 degrees equals 2? radians (approximately 6.28318)
  • The function accepts both integer and float values

Conclusion

The deg2rad() function provides an easy way to convert degrees to radians for mathematical calculations. It's particularly useful when working with trigonometric functions that expect radian input.

Updated on: 2026-03-15T07:26:52+05:30

147 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements