- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Is PHP deg2rad() equal to MySQL radians()?
Yes, both of these methods convert a degree value to radian. Let us create a table to understand MySQL radians. The query to create a table is as follows
mysql> create table RadiansDemo - > ( - > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, - > Value int - > ); Query OK, 0 rows affected (0.58 sec)
Insert some records in the table using insert command.
The query is as follows
mysql> insert into RadiansDemo(Value) values(0); Query OK, 1 row affected (0.14 sec) mysql> insert into RadiansDemo(Value) values(45); Query OK, 1 row affected (0.17 sec) mysql> insert into RadiansDemo(Value) values(90); Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement.
The query is as follows
mysql> select *from RadiansDemo;
The following is the output
+----+-------+ | Id | Value | +----+-------+ | 1 | 0 | | 2 | 45 | | 3 | 90 | +----+-------+ 3 rows in set (0.00 sec)
The following is the query to get the MySQL radians for degree value 0,45,90:
mysql> select radians(Value) from RadiansDemo;
The following is the output
+--------------------+ | radians(Value) | +--------------------+ | 0 | | 0.7853981633974483 | | 1.5707963267948966 | +--------------------+ 3 rows in set (0.03 sec)
Now we will consider PHP code to check if PHP gives the same result or not. The PHP code is as follows
$firstValue = 0; $secondValue = 45; $ThirdValue = 90; echo (var_dump(deg2rad($firstValue))); echo '<br>'; echo (var_dump(deg2rad($secondValue))); echo '<br>'; echo (var_dump(deg2rad($ThirdValue))); echo '<br>';
The following is the output displaying both the methods give the same result in radians i.e. converting degree to radians
float(0) float(0.78539816339745) float(1.5707963267949)
Advertisements
To Continue Learning Please Login
Login with Google