Question: I am having trouble with my IF statement, it is always TRUE although this is incorrect. I'm using an OR operator as there are two possible scenarios I want to capture in the IF statement. 

The array string ad\_status is "1" but using the below -3 is returned, I'm expecting the IF to be FALSE. If I remove the OR and second statement from the IF, the result of the IF is correct. 

What have I done wrong? Thanks.

```
    if(($getadstatus['ad_status'] != "1" || $getadstatus['ad_status'] != "4"))
    {
        return -3;
        exit;
    }

```

Additional:
What I want to do is exit the function (not seen in full here) if ad\_status does not equal 1 or 4. If it equals any other value other than 1 or 4, the IF statement should return TRUE and exit. 
ad\_status could be any value from 0 to 4.

Answer: 
There are no errors there.

If `ad_status == 1` then your second condition will get you into the If

```
$getadstatus['ad_status'] != "4"

```

is true therefore you will get `return -3;`

If i got what you want you should use `AND`

```
if ( $a!= 1 AND $a!= 4 )

```
> 
> humm, ok I think I see. I'm attempting to be too clever. I want to use a single IF statement to check for two non related conditions. If ad\_status does not equal 1 OR 4, return -3 and exit the function. 
> 
> 
> 

Okay, no problem, that can be expressed, just formulate like you write:

```
$status = $getadstatus['ad_status']; // assign a variable as it makes things easier to read.
if ( !( $status==1 || $status==4 ) )
{
    return -3;
}

```

So the `!` (not) should be on the whole OR comparison as you wrote in your sentence. That's probably in code what you had originally in mind. But as the order is important, the other part of your condition needs to be inside brackets to be calculated first, before using the not (`!`) operator.

Added:

The more sub-conditions are part of a condition or expression, the more complex it gets. But the more often you formulate complex conditions the better you will get with them. To train, you can always split conditions over multiple lines and assign labels (variables) to their part:

```
$status = $getadstatus['ad_status'];
$statusIs1or4 = $status==1 || $status==4;
$statusIsNot1or4 = !$statusIs1or4;
if ($statusIsNot1or4) return -3;

```

For production code this might be overuse, but as it's always the authors choice how to write something, you can do whatever the language allows.