If condition A is matched, condition B needs to be matched in order to do action C

Your first step in these kinds of problems is always to make a logic table.

A | B | Result
-------------------
T | T | do action C
T | F | ...
F | T | do action C
F | F | do action C

Once you’ve made the table, the solution is clear.

if (A && !B) {
  ...
}
else {
  do action C
}

Do note that this logic, while shorter, may be difficult for future programmers to maintain.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)