Sorry if this is a comp-sci 101 question. I'm just unsure if I'm missing something obvious.
So let's say some user input throws an error, and I want to catch it and return some feedback. The error will be a number, 0 - 8. 0 means "No Error". I want to give the user very specific feedback if the error is 3 (No numbers allowed, let's say). For the other 7 possibilities, I just want to end the script and echo the error.
I was working this out and decided to go with this:
$no_errors ($_error != 0 || $_error != 3) ? FALSE : TRUE;
if (!$no_errors)
echo $error_msg['$_error'];
$error_3 ($no_errors && $_error == 3) ? TRUE : FALSE;
if ($error_3)
bunch of stuff happens;
else
bunch of other stuff;
Anyways, I was then noticing the OR operator on the first line and was thinking that it might be better/safer to user an AND operator. But the more I contemplate, the less I see a difference.
So the real question is, if you want to eliminate two possibilities of a specific variable, are AND and OR identical, or is one logically/functionally more optimal?