Reputation: 4264
I want to check if multiple conditions are true/false with php. So I have
$a = 'hello';
In the below I expect to return false as a does = hello
var_dump(($a !== 'hello'));
bool(false)
this works as expected,
however If I try and ad an or in as shown below it returns true.
var_dump(($a !== 'hello')||($a !== 'bye'));
bool(true)
Why is this and how can I structure this so that I get false?
Upvotes: 1
Views: 626
Reputation: 495
You need to use AND. You check if $a isn't hello OR if $a isn't bye. The second one returns true.
var_dump($a !== 'hello' && $a !== 'bye');
Upvotes: 5
Reputation: 7658
Because $a !== 'bye'
...since it is hello
$a isn't 'hello' OR $a isn't 'bye'
Well, it isn't 'bye' because it's 'hello'. Therefore, the test is true
Upvotes: 0