在下面的PHP,如果我比較使用==它的工作原理,因爲我希望它,如果我用!=然後我的代碼休息,有人可以解釋或幫助一個變量?PHP的if/else錯誤
$_GET['p'] = 'home';
// DOES NOT work, it will always return "show JS" regardless to what string I have
if ($_GET['p'] != 'home' || $_GET['p'] != 'create.account'){
echo 'show JS';
}else{
echo 'do not show JS';
}
// Works as I would expect it to
if ($_GET['p'] == 'home' || $_GET['p'] == 'create.account'){
echo 'do not show JS';
}else{
echo 'show JS';
}
偉大的作品 – JasonDavis 2009-09-02 22:42:54
+1簡單德摩根定律(http://en.wikipedia.org/wiki/Demorgan%27s_law) – 2009-09-02 22:44:14