我不完全確定你想要什麼,但該邏輯將始終評估爲true
。您可能需要使用AND(& &),而不是OR(||)
所測試過的最遠的語句是($str != "danielle"
)和只有兩種可能的結果是PHP儘快進入塊作爲聲明成真。
這是第一個:
$str = "dan";
$str != "joe" # true - enter block
$str != "danielle" #ignored
$str != "heather" #ignored
$str != "laurie" #ignored
$str != "dan" #ignored
這是第二次:
$str = "joe";
$str != "joe" # false - continue evaluating
$str != "danielle" # true - enter block
$str != "heather" #ignored
$str != "laurie" #ignored
$str != "dan" #ignored
如果OR改爲然後保持評估,直到返回false:
$str = "dan";
$str != "joe" # true - keep evaluating
$str != "danielle" # true - keep evaluating
$str != "heather" # true - keep evaluating
$str != "laurie" # true - keep evaluating
$str != "dan" # false - do not enter block
雖然解決方案不能很好地擴展,但您應該保留一個排除列表數組並檢查它:
$str = "dan";
$exclude_list = array("joe","danielle","heather","laurie","dan")
if(!in_array($str, $exclude_list)){
echo " <a href='/about/".$str.".php'>Get to know ".get_the_author_meta('first_name')." →</a>";
}
你有什麼期望發生請描述? – lam3r4370 2011-06-10 19:15:32
怎麼回事? – 2011-06-10 19:15:49
另外,你的變量被設置爲'dan',你檢查變量是不是丹(或其他),並回應一些東西。我認爲你期望看到信息,用echo輸出,但你的變量是'dan'。 – lam3r4370 2011-06-10 19:18:35