【发布时间】:2012-02-07 10:34:01
【问题描述】:
我不确定我的 IF 语句是否正确 -
我希望代码结束如果变量
$answer不是'4'或'four'。如果变量
$answer等于 4 或 4 - 程序继续处理代码。
感谢您的帮助。
谢谢
if( ! in_array($answer, array(4, 'four')))
{
//if answer is not in an array containing either 4 or four then..
echo "You have entered the security question incorrectly. Your request will NOT be processed";
exit();
}
else
{
if ($from != "")
{
//test send mail to Melanie
mail($to, $subject, $contents, $from_header);
// redirect back to url visitor came from
$display_blockmsg = "Thank you, <b>$_POST[title] $_POST[firstname] $_POST[lastname]</b>, <br>
Your contact form details have been sent to us <br>
Your contact details are:<br><br>
<b>Address:</b> $_POST[address1]
$_POST[address2],<br>
<b>City:</b> $_POST[city]<br>
<b>County:</b> $_POST[county]<br>
<b>Postcode:</b> $_POST[postcode]<br>
<b>Country:</b> $_POST[country]<br>
<b>Telephone:</b> $_POST[telephone]<br>
<b>email:</b> $_POST[from]<br><br>";
}
else
{
$display_blockmsg = "<center><b>The email field</b> is empty. Please go back and complete this field.</center>";
}
} //end of first else ...if
【问题讨论】: