计算器

<?php
$value='';
if (!empty($_POST)){
    $one=$_POST['one'];
    $two=$_POST['two'];
    $fuhao=$_POST['fuhao'];
    if ($fuhao=='+'){
        $value=$one+$two;
    }
    if ($fuhao=='-'){
        $value=$one-$two;
    }
    if ($fuhao=='*'){
        $value=$one*$two;
    }
    if ($fuhao=='/'){
        $value=$one/$two;
    }
    echo $value;
}
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>计算器</title>
</head>
<body>
<form action="" method="post">
    第一个数:<input type="text" name="one"><br>
    <input type="radio" name="fuhao"value="+">+&nbsp;
    <input type="radio" name="fuhao"value="-">-&nbsp;
    <input type="radio" name="fuhao"value="*">*&nbsp;
    <input type="radio" name="fuhao"value="/">/<br>
    第二个数:<input type="text" name="two"><br>
    <input type="submit">
</form>
</body>
</html>

 

posted @ 2022-06-08 19:50  橙大力  阅读(14)  评论(0)    收藏  举报