yakoup46 Posted April 20, 2009 Share Posted April 20, 2009 <html> <head> <title></title> </head> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <select name="trig"> <option value="sin">Sin ( )</option> <option value="cos">Cos ( )</option> <option value="tan">Tan ( )</option> </select> <select name="deg_rad"> <option value="rad">Radians</option> <option value="deg">Degrees</option> </select> <input type="text" name="trig_value"> <input type="submit" value="Solve"> </form> <?php $find_trig = @$_POST['trig']; $deg_rad = @$_POST['deg_rad']; $trig_value = @$_POST['trig_value']; $deg = rad2deg($trig_value); if($find_trig == 'sin' && $deg_rad == 'rad') echo (sin($trig_value)); else if($find_trig == 'sin' && $deg_rad == 'deg') echo $deg; ?> I don't know what i am doing wrong. The radians works but when i try degrees i get a weird number. </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/154811-deg2rad-wont-work/ Share on other sites More sharing options...
Daniel0 Posted April 20, 2009 Share Posted April 20, 2009 If you read the manual, the trigonometric functions take a radian value as argument. Quote Link to comment https://forums.phpfreaks.com/topic/154811-deg2rad-wont-work/#findComment-814282 Share on other sites More sharing options...
yakoup46 Posted April 20, 2009 Author Share Posted April 20, 2009 Ooops. my code said rad2deg title doesn't sorry. Now that i have that cleared up, i know that it give a radian, that is why in my code i used rad2deg. Quote Link to comment https://forums.phpfreaks.com/topic/154811-deg2rad-wont-work/#findComment-814546 Share on other sites More sharing options...
DarkSuperHero Posted April 26, 2009 Share Posted April 26, 2009 <html> <head> <title></title> </head> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <select name="trig"> <option value="sin">Sin ( )</option> <option value="cos">Cos ( )</option> <option value="tan">Tan ( )</option> </select> <select name="deg_rad"> <option value="rad">Radians</option> <option value="deg">Degrees</option> </select> <input type="text" name="trig_value"> <input type="submit" value="Solve"> </form> <?php $find_trig = $_POST['trig']; $deg_rad = $_POST['deg_rad']; $trig_value = ($_POST['deg_rad'] == 'rad')? $_POST['trig_value'] : deg2rad($_POST['trig_value']); if($find_trig == 'sin') { echo (sin($trig_value)); } else if($find_trig == 'tan'){ echo (tan($trig_value)); } else if($find_trig == 'cos'){ echo (cos($trig_value)); } ?> </body> </html> try that... Quote Link to comment https://forums.phpfreaks.com/topic/154811-deg2rad-wont-work/#findComment-819602 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.