Function class
$a =$_request["NUM1"];
$b =$_request["num2"];
$fuhao =$_request["Fuhao"];
Class cat{
Public function Jisuan ($a, $b, $fuhao) {
Switch ($fuhao) {
Case "+":
$a + $b;
Echo ' $a + $b = '. $a + $b;
Break
Case "-":
$a-$b;
Echo ' $a-$b = '. $a-$b;
Break
Case "*":
$a * $b;
Echo ' $a * $b = '. $a * $b;
Break
Case "/":
$a/$b;
echo ' $a/$b = '. $a/$b;
Break
}
}
}
$cat 1=new Cat ();
$cat 1->jisuan ($a, $b, $fuhao);
?>
Reply to discussion (solution)
It's working, you can calculate.
The amount ... The topic did not see clearly, should be the priority of the question, you put the case "+":
$a + $b;
Echo ' $a + $b = '. ($a + $b);
Break
Case "-":
$a-$b;
Echo ' $a-$b = '. ($a-$b);
Break
Change to Case "+":
$a + $b;
Echo ' $a + $b = '. $a + $b;
Break
Case "-":
$a-$b;
Echo ' $a-$b = '. $a-$b;
Break
Develop the habit of adding brackets
Echo ' $a-$b = '. ($a-$b); Echo ' $a-$b = ', $a-$b;
$c = $a + $b; Echo ' $a + $b = '. $c;