尝试添加第4个else语句,但它不起作用。无法在网上找到适用的示例。前3个声明有效,但不是第4声明。应该是If,elseif,elseif,else还是if,elseif,else,else?If else语句
if(empty($fromName) or empty($fromEmail) or empty($subject) or empty($comments)) {
echo 'You cannot submit the form with empty fields. Please correct the form and resubmit.';
return false;
}
elseif($fieldDelete == "Delete this text!"){
$msg ="Delete the contents of the fourth field before submitting.";
print $msg;
}
else {
$flgchk = mail ("$to", "$subject", "$message", "$headers");
$imgfile = "images/NatMap logo2.gif";
$handle = fopen($filename, "r");
$imgbinary = fread(fopen($imgfile, "r"), filesize($imgfile));
echo '<img src="data:image/gif;base64,' . base64_encode($imgbinary) . '" width=427 height=72 />';
echo "\n<br />\n<br />Thank You! An e-mail has been sent to the National Map web team and they will get back to you in the next 24-48 hours.";
}
else ($fieldDelete == "Delete this text!"){
$msg ="Delete the contents of the fourth field before submitting.";
print $msg;
}
显然,除非你把第三个成'elseif'你不能添加第四个'if'。阅读你已经编写的代码。 –
每个'if'只能有一个'else'语句。如果没有'if'或'elseif'测试匹配,则使用它。另一个是什么意思? – Barmar
你不能在'else'之后有条件。它必须是'elseif'。它需要在“其他”之前。 – Barmar