IF / ELSEIF / ELSE失误

时间:2013-06-12 15:30:23

标签: php

$type = trim(strip_tags(stripslashes($_GET['type'])));
$referer = $_SERVER["HTTP_REFERER"];     

if ($type == "Clinical" && $referer == "al.php?zh=loadPage") {
    echo "clinical";
}
elseif ($type == "AnnualEducation" && referer == "ual.php?zh=loadPage") {
    echo "annual";
}
else {
    echo "neither";
}

我遇到的问题是,如果类型为Clinicalal.php?zh=loadpage,那么IF会触发(这是正确的)但是当类型为AnnualEducationual.php?zh=loadpage时ELSE开火了。不知怎的,正在跳过elseif。

有什么想法解决它?

1 个答案:

答案 0 :(得分:6)

elseif

elseif ($type == "AnnualEducation" && referer == "ual.php?zh=loadPage") {

应该是

elseif ($type == "AnnualEducation" && $referer == "ual.php?zh=loadPage") {

{1}}

中缺少$