php入门 我第一次的小程序if(!empty($_POST['symbol'])){
$num1=$_POST['num1'];
$num2=$_POST['num2'];
$symbol=$_POST['symbol'];
$result="";
if($symbol=="+"){
$result=$num1+$num2;
}elseif($symbol=="-"){
$result=$num1-$num2;
}elseif($symbol=="*"){
$result=$num1*$num2;
}elseif($symbol=="/"){
$result=$num1/$num2;
//对除法的结果进行四舍五入
$result=round($result,2);
}
echo "计算结果是:$result";
}
2022-03-07 18:13:51
2KB
php
1