Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/23/2020 in all areas

  1. The logic $number != 101 OR $number != 102 is always true. Look at the conditions separately for various cases: Case 1) $number = 99 $number != 101 => true $number != 102 => true true || true => true Case 2) $number = 101 $number != 101 => false $number != 102 => true false || true => true Case 3) $number = 102 $number != 101 => true $number != 102 => false true || false => true What you want is AND, not OR. Case 1) $number = 99 $number != 101 => true $number != 102 => true true && true => true Case 2) $number = 101 $number != 101 => false $number != 102 => true false && true => false Case 3) $number = 102 $number != 101 => true $number != 102 => false true && false => false
    1 point
  2. Think about your logic. If $number is 101 then it <>102, right? And if $number is 102 then it <>101, right? Also, please do what the rest of the PHP community does: use the && || != operators instead of AND OR <>. The first group is what you see in programming languages. The second group is what you see in SQL. PHP is not SQL.
    1 point
  3. When mixing AND and OR in expressions, use parentheses to make the logic explicit. For example, instead of if (A AND B OR C) use one of these, depending on what you mean if ( (A AND B) OR C ) or if ( A AND ( B OR C ) )
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.