php制作计算器的问题
发布网友
发布时间:2022-04-29 15:35
我来回答
共1个回答
热心网友
时间:2023-10-15 23:27
<html>
<title>
计算器
</title>
<body>
<form
method=post>
操作数1:
<input
type=text
name=num1><br>
操作数2:
<input
type=text
name=num2><br>
<p>
选择你要进行的操作<br>
<input
type=radio
name=operation
value="加"
checked>加<br>
<input
type=radio
name=operation
value="减">减<br>
<input
type=radio
name=operation
value="乘">乘<br>
<input
type=radio
name=operation
value="除">除<br>
<input
type=submit><input
type=reset>
</form>
<hr>
<?
$num1
=
$_POST["num1"];
$num2
=
$_POST["num2"];
$op
=
$_POST["operation"];
switch($op){
case
"加":
echo
$num1;
echo
"
+
";
echo
$num2;
echo
"
=
";
echo
$num1
+
$num2;
break;
case
"减":
echo
$num1;
echo
"
-
";
echo
$num2;
echo
"
=
";
echo
$num1
-
$num2;
break;
case
"乘":
echo
$num1;
echo
"
*
";
echo
$num2;
echo
"
=
";
echo
$num1
*
$num2;
break;
case
"除":
echo
$num1;
echo
"
/
";
echo
$num2;
echo
"
=
";
echo
$num1
/
$num2;
break;
}
?>
</body>
</html>
热心网友
时间:2023-10-15 23:27
<html>
<title>
计算器
</title>
<body>
<form
method=post>
操作数1:
<input
type=text
name=num1><br>
操作数2:
<input
type=text
name=num2><br>
<p>
选择你要进行的操作<br>
<input
type=radio
name=operation
value="加"
checked>加<br>
<input
type=radio
name=operation
value="减">减<br>
<input
type=radio
name=operation
value="乘">乘<br>
<input
type=radio
name=operation
value="除">除<br>
<input
type=submit><input
type=reset>
</form>
<hr>
<?
$num1
=
$_POST["num1"];
$num2
=
$_POST["num2"];
$op
=
$_POST["operation"];
switch($op){
case
"加":
echo
$num1;
echo
"
+
";
echo
$num2;
echo
"
=
";
echo
$num1
+
$num2;
break;
case
"减":
echo
$num1;
echo
"
-
";
echo
$num2;
echo
"
=
";
echo
$num1
-
$num2;
break;
case
"乘":
echo
$num1;
echo
"
*
";
echo
$num2;
echo
"
=
";
echo
$num1
*
$num2;
break;
case
"除":
echo
$num1;
echo
"
/
";
echo
$num2;
echo
"
=
";
echo
$num1
/
$num2;
break;
}
?>
</body>
</html>
热心网友
时间:2023-10-15 23:27
<html>
<title>
计算器
</title>
<body>
<form
method=post>
操作数1:
<input
type=text
name=num1><br>
操作数2:
<input
type=text
name=num2><br>
<p>
选择你要进行的操作<br>
<input
type=radio
name=operation
value="加"
checked>加<br>
<input
type=radio
name=operation
value="减">减<br>
<input
type=radio
name=operation
value="乘">乘<br>
<input
type=radio
name=operation
value="除">除<br>
<input
type=submit><input
type=reset>
</form>
<hr>
<?
$num1
=
$_POST["num1"];
$num2
=
$_POST["num2"];
$op
=
$_POST["operation"];
switch($op){
case
"加":
echo
$num1;
echo
"
+
";
echo
$num2;
echo
"
=
";
echo
$num1
+
$num2;
break;
case
"减":
echo
$num1;
echo
"
-
";
echo
$num2;
echo
"
=
";
echo
$num1
-
$num2;
break;
case
"乘":
echo
$num1;
echo
"
*
";
echo
$num2;
echo
"
=
";
echo
$num1
*
$num2;
break;
case
"除":
echo
$num1;
echo
"
/
";
echo
$num2;
echo
"
=
";
echo
$num1
/
$num2;
break;
}
?>
</body>
</html>
热心网友
时间:2023-11-07 00:24
<html>
<title>
计算器
</title>
<body>
<form
method=post>
操作数1:
<input
type=text
name=num1><br>
操作数2:
<input
type=text
name=num2><br>
<p>
选择你要进行的操作<br>
<input
type=radio
name=operation
value="加"
checked>加<br>
<input
type=radio
name=operation
value="减">减<br>
<input
type=radio
name=operation
value="乘">乘<br>
<input
type=radio
name=operation
value="除">除<br>
<input
type=submit><input
type=reset>
</form>
<hr>
<?
$num1
=
$_POST["num1"];
$num2
=
$_POST["num2"];
$op
=
$_POST["operation"];
switch($op){
case
"加":
echo
$num1;
echo
"
+
";
echo
$num2;
echo
"
=
";
echo
$num1
+
$num2;
break;
case
"减":
echo
$num1;
echo
"
-
";
echo
$num2;
echo
"
=
";
echo
$num1
-
$num2;
break;
case
"乘":
echo
$num1;
echo
"
*
";
echo
$num2;
echo
"
=
";
echo
$num1
*
$num2;
break;
case
"除":
echo
$num1;
echo
"
/
";
echo
$num2;
echo
"
=
";
echo
$num1
/
$num2;
break;
}
?>
</body>
</html>
热心网友
时间:2023-10-15 23:27
<html>
<title>
计算器
</title>
<body>
<form
method=post>
操作数1:
<input
type=text
name=num1><br>
操作数2:
<input
type=text
name=num2><br>
<p>
选择你要进行的操作<br>
<input
type=radio
name=operation
value="加"
checked>加<br>
<input
type=radio
name=operation
value="减">减<br>
<input
type=radio
name=operation
value="乘">乘<br>
<input
type=radio
name=operation
value="除">除<br>
<input
type=submit><input
type=reset>
</form>
<hr>
<?
$num1
=
$_POST["num1"];
$num2
=
$_POST["num2"];
$op
=
$_POST["operation"];
switch($op){
case
"加":
echo
$num1;
echo
"
+
";
echo
$num2;
echo
"
=
";
echo
$num1
+
$num2;
break;
case
"减":
echo
$num1;
echo
"
-
";
echo
$num2;
echo
"
=
";
echo
$num1
-
$num2;
break;
case
"乘":
echo
$num1;
echo
"
*
";
echo
$num2;
echo
"
=
";
echo
$num1
*
$num2;
break;
case
"除":
echo
$num1;
echo
"
/
";
echo
$num2;
echo
"
=
";
echo
$num1
/
$num2;
break;
}
?>
</body>
</html>