The problem is that you put your expressions in strings!
Your $condition1 , $condition2 and $condition3 variables contain strings, not the result of the expression, and the same applies to your $condition variable, which will be a string that looks like 53==56||53==57||53==58 . When PHP evaluates the string, it considers it true if it is not empty and not equal to 0 , so your script will output blah .
To fix this, you just need to extract the expressions from the strings. It should look like this:
$condition1 = 53 == 56; // false $condition2 = 53 == 57; // false $condition3 = 53 == 58; // false $condition = $condition1 || $condition2 || $condition3; // false || false || false = false if ($condition) { echo 'blah'; } else { echo 'foo'; // This will be output }
source share