Skip to content

Instantly share code, notes, and snippets.

@masamasa6210
Created November 28, 2016 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masamasa6210/c2a155b8f9bd03cdefc1aafcb250e43f to your computer and use it in GitHub Desktop.
Save masamasa6210/c2a155b8f9bd03cdefc1aafcb250e43f to your computer and use it in GitHub Desktop.
<html>
<head>
<title>calc.php</title>
</head>
<body>
<?php
//値を習得
if (isset($_POST["selOpe"])){
$a = $_POST['txtA'];
$b = $_POST['txtB'];
$ope = $_POST['selOpe'];
//セレクトボックスによって処理を変える
switch($ope){
case "+":
$answer = $a+$b;
break;
case "-":
$answer = $a-$b;
break;
case "×":
$answer = $a*$b;
break;
case "÷":
$answer = $a/$b;
break;
default;
break;
}
//計算結果を表示
print($a."".$ope."".$b."=".$answer."\n");
}
?>
<br/>
<br/>
<a href="#" onclick="history.back(); return false;">前の画面に戻る</a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment