```
[b]code1[/b]
<?php
$myVar=[COLOR="red"]1[/COLOR];
if (!$myVar==[SIZE="5"]0[/SIZE])
{
echo $myVar;
}
?>
//if $myVar is not 0, then print $myVar.
```

The code above print 1 . It works fine.

```
[b]code2[/b]
<?php
$myVar=[COLOR="red"]1[/COLOR];
if (!$myVar==[SIZE="5"]2[/SIZE])
{
echo $myVar;
}
?>
//if $myVar is not 2, then print $myVar.
```

I am expecting that the code above print 1 .
But it doesn’t print 1 .

What’s wrong in the code2 ?
How can I correctly write for the meaning of “if $myVar is not 2, then print $myVar.”?

if (!$myVar==2) is not “if $myVar does not equal 2”, it is “if !$myVar equals 2”, that is to say “if the boolean negation of $myVar equals 2”.
Since $myVar is 1, which has a boolean value of true, the boolean negation of $myVar is false. Since false doesn’t equal 2 the condition in the if in your second snippet doesn’t validate to true.

What you seem to want is

if ($myVar != 2)

You could throw some parentheses around it though.

```
<?php
$var = 1;
var_dump(! ($var == 2) ); #true
```

Thank you, ScallioXTX.

Thank you, AnthonySterling.

I think the problem is your “2” is too big

This will also be useful.

In mathematics and mathematical logic, Boolean algebra is a branch of algebra. It differs from elementary algebra in two ways. First, the values of the variables are the truth values true and false, usually denoted 1 and 0, whereas in elementary algebra the values of the variables are numbers. Second, Boolean algebra uses logical operators such as conjunction (and) denoted as ∧, disjunction (or) denoted as ∨, and the negation (not) denoted as ¬. Elementary algebra, on the other hand, uses arith...