mardi 15 décembre 2015

Does PHP || or operator work with != not is equal to operator

I have a question. Lately I was working with a IF condition which is:

if ($var1 != 'this' || $var2 != 'that') {
    // Do a dance
} else {
    // Cook something
}

But that doesn't work for me. But if I use it like this:

if ($var1 == 'this' || $var2 == 'that') {
    // Cook something
} else {
    // Do a dance
}

So why did my IF condition with != doesn't work?

Just wanted to know the difference so I can use it properly in future :)

Aucun commentaire:

Enregistrer un commentaire