当使用if和else时,AND运算符的否定是什么


What is the negation of the AND operator when using if and else?

我使用if&&,然后是else

示例:

$Name = "john";
$age = "30";

如果我这样做:

if($Name =="john" && $age=="30") 
{ some stuff }
else { do other stuff }

这里的其他意思是:$Name !="john" && $age != "30"??我对此有点困惑。

感谢

$Name == "john";
$age == "30";
if($Name =="john" && $age=="30") 
{
   // Here comes only when name is john and age is 30
}
else 
{ 
  // Here comes all the time when name is not john AND age is not 30
  // If age is 30 and name is not John then comes here
  // If age is not 30 and name is John then comes here
}

amp&操作员只有在所有条件均为真实时才工作

if($Name =="john" && $age=="30") {// both are true}

else条件是其中一个为false,或者两个都为false,就像下面的条件。。。

($Name !="john" && $age == "30")
($Name == "john" && $age != "30")
($Name != "john" && $age != "30)

在更复杂的情况下,您可以绘制一个真值表来更好地理解您的表达式:

$Name=="john" ? | $age=="30" ? | ($Name =="john" && $age=="30") 
----------------+--------------+-------------------------------
        0  (no) |      0  (no) |                     0 (false)
        0  (no) |      1 (yes) |                     0 (false)
        1 (yes) |      0  (no) |                     0 (false)
        1 (yes) |      1 (yes) |                     1  (true)