Copy CodeThe code is as follows:
<title>PHP Implementation Simple Calculator</title>
Single-channel Branch
if (Isset ($_get["sub"]))
{
$num 1=true;//Whether the number 1 is an empty tag
$num 2=true;//Whether the number 2 is an empty tag
$numa =true;//Number 1 is a number
$numb =true;//Number 2 is a bit number
$message = "";
Determines whether the number 1 is empty
if ($_get["NUM1"]== "")
{
$num 1=false;
$message. = "The first number cannot be empty";
}
Determine if the number 1 is a number
if (!is_numeric ($_get["NUM1"))
{
$numa =false;
$message. = "The first number is not a number";
}
Determine if the number 2 is a number
if (!is_numeric ($_get["num2"))
{
$numa =false;
$message. = "The second number is not a number";
}
Determines whether the number 2 is empty
if ($_get["num2"]== "")
{
$num 2=false;
$message. = "The second number cannot be empty";
}
if ($num 1 && $num 2 && $numa && $numb)
{
$sum = 0;
Multi-Channel Branch
Switch ($_get["YSF"]) {
Case "+":
$sum =$_get["NUM1"]+$_get["num2"];
Break
Case "-":
$sum =$_get["NUM1"]-$_get["num2"];
Break
Case "X":
$sum =$_get["NUM1"]*$_get["num2"];
Break
Case "/":
$sum =$_get["NUM1"]/$_get["num2"];
Break
Case "%":
$sum =$_get["NUM1"]%$_get["num2"];
Break
}
}
}
?>
http://www.bkjia.com/PHPjc/323562.html www.bkjia.com true http://www.bkjia.com/PHPjc/323562.html techarticle Copy the code code as follows: HTML head titlephp implementation simple calculator/title meta http-equiv= "Content-type" content= "text/html;charset=gb2312"/head ? PHP//Single channel branch if (Isset ($_get[ ...