PHP deg2rad() Function Last Updated : 22 Jun, 2023 Comments Improve Suggest changes Like Article Like Report Among the methods to measure angles, the two most commonly used are degrees and radians. Students typically learn about degree while learning about radian becomes a later concern. But there are certain cases where radian is the preferred unit of measurement such as: While working with the derivatives of trigonometric functions, it is preferable to use the radian measure for angles, because then derivative are easier as the pi is avoided. In order to derive the relation between linear velocity and angular velocity for any motion in a circle, while using the radian measurement it produces the velocity in natural units i.e. m/s but if we use degrees then we get the velocity in the unit of m.degree/s which has to undergone through another conversion to be in natural form. Thus in some cases it is required to convert from degrees to radian, this is where the method deg2rad() comes in aid. Syntax: float deg2rad ($value) Parameters: The function takes a single parameters which is a float that represents the angle in degrees. Return Type: This function returns a float value that represents the radian equivalent of the angle. Examples: Input : $deg = 45; Output : 0.78539816339745 Input : $deg = 90; Output : 1.5707963267949 Input : $deg = 180; Output : 3.1415926535898 Below program illustrates the working of deg2rad() in PHP: PHP <?php // PHP code to illustrate the working of deg2rad() $deg = 22.5; $k = 8; for(;$k>=1;$k/=2, $deg*=2) { if($k!=1) echo 'pi/'.$k.' = '.deg2rad($deg).'<br>'; else echo 'pi = '.deg2rad($deg).'<br>'; } ?> Output: pi/8 = 0.39269908169872 pi/4 = 0.78539816339745 pi/2 = 1.5707963267949 pi = 3.1415926535898 Important points to note: It calculates the Radian equivalent of the angle given in degrees. The counterpart of the method is deg2rad(). This method produces highly accurate results but is not much time efficient. Reference: http://php.net/manual/en/function.deg2rad.php Comment More infoAdvertise with us Next Article PHP deg2rad() Function P PronabM Follow Improve Article Tags : Misc Web Technologies PHP PHP-math PHP-function +1 More Practice Tags : Misc Similar Reads PHP ereg() Function The Ereg() function in PHP searches a string to match the regular expression given in the pattern. The function is case-sensitive. This function has been deprecated in PHP 5.3.0 and removed in PHP 7.0.0. Syntax: int ereg ( string $pattern , string $str, array &$arr ); Parameters: pattern: It is 2 min read PHP asin( ) Function Trigonometry is an important part of mathematics and PHPâs math functions provides us with some functions which are very useful for calculations involving trigonometry. One of such function is asin() function. The asin() function in PHP is used to find the arc sine of a number in radians. We already 2 min read PHP atan( ) Function Trigonometry is an important part of mathematics and PHPâs math functions provides us with some functions which are very useful for calculations involving trigonometry. One of such function is atan() function. The atan() function in PHP is used to find the arc tangent of an argument passed to it whi 2 min read PHP acos( ) Function Trigonometry is an important part of mathematics and PHPâs math functions provides us with some functions which are very useful for calculations involving trigonometry. One of such function is acos() function. The acos() function in PHP is used to find the arc cosine of a number in radians. We alrea 2 min read PHP atan2( ) Function The atan2() function is a builtin function in PHP and is used to calculate the arc tangent of two variables x and y passed to it as arguments. The function returns the result in radians, which is between -Pi and Pi (inclusive). Syntax: float atan2($y, $x) Parameters: This function accepts two parame 1 min read Like