看看PHP中的哪个变量触发了If语句?

时间:2014-05-23 15:42:41

标签: php if-statement syntax syntax-error

$one=$_POST['one'];
$two=$_POST['two'];
$three=$_POST['three'];
$four=$_POST['four'];
$five=$_POST['five'];
$six=$_POST['six'];
$seven=$_POST['seven'];
$eight=$_POST['eight'];
$nine=$_POST['nine'];
$ten=$_POST['ten'];
if ( $one   == "gift" or $two   == "gift" or $three == "gift" or $four  == "gift" or $five  == "gift" or $six   == "gift" or $seven == "gift" or $eight == "gift" or $nine  == "gift" or $ten   == "gift" ) {
 echo "<meta http-equiv='refresh' content='0; url=./gift.php?item=" . ??? . "' />";
}

我该怎么办?填写触发if语句的变量名...

1 个答案:

答案 0 :(得分:7)

$key = array_search('gift', $_POST);
if ($key) {
    echo "$key equals 'gift'";
} else {
    echo "nothing equals 'gift'";
}