嘗試添加第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