Why I write this program of $a+ $b and $a-$b can not calculate, other can calculate Ah, ask the big God solve!!!
$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);
?> function class
Share to:
------Solution--------------------
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