有人可以检查我的计算器是否可以工作?

时间:2019-11-29 16:48:27

标签: php

我不确定该计算器是否可以正常工作,因为我以前从未编码过,所以如果有人可以检查并给我一些反馈,我将不胜感激

html部分

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title of the document</title>
</head>

<body>

<form>
    <input type="text" name="num1" placeholder="Number 1">
    <select name="operator">
        <option>none</option>
        <option>no grādiem uz radiāniem</option>
        <option>no radiāniem uz grādiem</option>
    </select>
    <br>
    <button type="submit" name="submit" value="submit">calculate</button>
</form>
<p>result</p>

php部分

<?php
  if (isset($_GET['submit'])) {
    $result1 = $_GET['num1'];
    $result2 = $_GET['num1'];
    $operator = $_GET['operator'];
    switch ($operator) {
     case "none":
         echo "no result";
     break;
     case "no grādiem uz radiāniem":
         echo "$result1 rad2deg(num1)";
     break;
     case "no radiāniem uz grādiem":
         echo "$result2 deg2rad(num1)";
        break;

    }

  }
?>

和html的结尾

</body>

</html>

0 个答案:

没有答案