Php 带有多个条件的if-else语句
我试图做的是在sql查询之前设置正确的变量。这是我创建的if语句,但是我无法使它正确地回显。下面提供的设置应回显fnm,但回显nm。我在这里错误地做了什么,使两个变量在每个if语句中匹配,以便插入正确的数据Php 带有多个条件的if-else语句,php,if-statement,Php,If Statement,我试图做的是在sql查询之前设置正确的变量。这是我创建的if语句,但是我无法使它正确地回显。下面提供的设置应回显fnm,但回显nm。我在这里错误地做了什么,使两个变量在每个if语句中匹配,以便插入正确的数据 $type = "No Notification"; $remote = "Yes"; if ($type == "No Notification" && $remote == "No"){ $type = "nm"; } elseif ($type == "Email No
$type = "No Notification";
$remote = "Yes";
if ($type == "No Notification" && $remote == "No"){
$type = "nm";
}
elseif ($type == "Email Notification" && $remote == "No"){
$type = "m";
}
elseif ($type == "No Notifcation" && $remote == "Yes"){
$type = "fnm";
}
elseif ($type == "Email Notification" && $remote == "Yes"){
$type = "fm";
}
else {
$type = "nm";
}
echo $type;
您的第二个elseif有一个输入错误:通知应该是通知
这些事情会发生:)什么是
var\u dump($type);变量转储(远程)代码>显示?(在代码开头添加行)字符串(2)“nm”字符串(3)“Yes”打字错误:通知缺失。错过了,,thanks@JoopEggen你让我明白了:)漂亮的眼睛。我花了一段时间才看到。