Jump to content

deg2rad won't work!


yakoup46

Recommended Posts

<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>

Link to comment
https://forums.phpfreaks.com/topic/154811-deg2rad-wont-work/
Share on other sites

<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...

Link to comment
https://forums.phpfreaks.com/topic/154811-deg2rad-wont-work/#findComment-819602
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.