Had this twice now, don't know what the problem is, I have this normal if statement, with an OR attribute
if((checkBlock($showU['id'], $USER, 'Wall') != 1) || (checkBlock($showU['id'], $USER, 'Wall', 1) == 1)) {
I want it to check whether the first checkBlock is != 1, OR if checkBlock is == 1
First if checkBlock should be true, if I have blocked an user and the user tries to visit me.
Second should开发者_JAVA百科 be true if I have blocked an user and I try to visit him.
The first ifstatement works with the code above, but not the if statement (the if i have blocked and visits him)..
But the second works if I remove the first statement.. but I want to check for both.
How can i make them both check work? I have tried OR, but didnt affect the issue.
PHP is skipping the second check when the first is true because of short-circuit boolean evaluation. That is, if you have (A || B) and A is true, then there's no need to check B because your conditional has already passed. If you want to check for both conditions then you need to use AND not OR.
Your starting condition doesn't make sense, whether you use AND or OR, your checking the same value (consider the interpreted value of your function like: 1 != 1 OR 1 == 1, that doesn't make sense). Please consider checking the values and your logic.
If you want to check them both, it should be AND (&&
), not OR
精彩评论