The php Function Deg2rad
The php function deg2rad converts a number from degrees to the radian equivalent. This is handy if you are using any trigonometric functions such as sin, cos or tan since they require the angle measurement to be passed in radians rather than degrees.
The built-in math functions in PHP cover most of the basic needs for most developers, with only a few exceptions. For instance, it’s possible to calculate the exponential and logarithmic functions like exp($value) and lcm(two arrays or a string and a value) from within the language itself. You can also use the definable constants e, sqrt, factorial, and pi to simplify these types of calculations.
However, the default return type for many of these functions is float (or int). You’ll need to be aware that you’re dealing with floating point numbers when using these functions. This is not the fault of PHP, but is a general issue with a programming language that is not ideally designed to work with floating point values.
Moreover, it is common for functions to return different types based on whether they were successful or not. This can cause confusion if you are using functions that don’t have a good documentation or the code is based on a C program. It’s important to check the documentation before you try to compare different functions’ return types. Using a wrapper such as mbstring is also not the best solution, because some of these functions will behave differently depending on the platform (eg, mbstring('