十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
PHP简单计算器
'; $result = 0.0; switch($_POST["opt"]){ case '+': $result = $_POST["num1"] + $_POST["num2"]; break; case '-': $result = $_POST["num1"] - $_POST["num2"]; break; case '*': $result = $_POST["num1"] * $_POST["num2"]; break; case '/': if($_POST["num2"] != "0"){ $result = $_POST["num1"] / $_POST["num2"]; } break; case '%': if($_POST["num2"] != "0"){ $result = $_POST["num1"] % $_POST["num2"]; } break; } if(!$message){ echo ''."计算结果:".$_POST["num1"]." ".$_POST["opt"]." ".$_POST["num2"]." = ".$result.""; }else{ echo '错误:'.$message.""; } echo ' | '; } ?>