I need to check if one of several values is not equal to some specified value. For example:
[php]
if($var != 1 || $var != 2 || $var != 3) {
echo ‘pass’;
} else {
echo ‘fail’;
}
[/php]
In such a case, I would expect it to show “pass” on the page if $var was not equal to 1, 2, or 3. If it were equal to any of those, I would expect it to show “fail” instead. What actually happens is it always says “pass”.
I have tried the following and it does what I want:
[php]
if($var != 1 && $var != 2) {
echo ‘pass’;
} else {
echo ‘fail’;
}
[/php]
However, it does not continue in this behavious if I add more than two items for it to test. Does anyone have any ideas on what I am doing wrong?