我对整个编程事情都很陌生,所以如果这是一个愚蠢的问题,请原谅我.我以前没碰过它似乎很奇怪.
我正在尝试为蛋糕订购.您填写表单,提交表单,然后在新窗口中显示订单,然后点击"提交",然后将其上传到数据库.在提交表单之前,我有一系列If语句来检查表单中的错误.这是代码的简化版本.写作意味着你想要的任何文字,名字是你的名字,蛋糕是你想要的蛋糕类型(默认为"无").
try {
$name = trim($params->name);
$cake = trim($params->cake);
$writing = trim($params->writing);
if (strlen($name) < 3){
throw new Exception("Please enter Your name.");
}
if ($cake = "None") {
throw new Exception("Please select a Cake"
}
if ($cake = "Caramel Apple Pie" or $cake = "Pumpkin Pie" or $cake = "Eggnog Pie" and strlen($writing) > 1) {
throw new Exception("We are sorry, but you can't write on any of our specialty pies.");
}
} catch(Exception $x) {
$error = $x->getmessage(); …Run Code Online (Sandbox Code Playgroud)