# IF Statements with OR (the syntax)

**URL:** <https://forum.kirupa.com/t/if-statements-with-or-the-syntax/228830>\
**Category:** programming\
**Created:** [June 11, 2007, 9:30pm UTC](https://forum.kirupa.com/t/if-statements-with-or-the-syntax/228830 "2007-06-11T21:30:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbailey](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jbailey/32/2380_2.png) [@jbailey](https://forum.kirupa.com/u/jbailey)\
**Post date:** [June 11, 2007, 9:30pm UTC](https://forum.kirupa.com/t/if-statements-with-or-the-syntax/228830/1 "2007-06-11T21:30:57Z")

</div>

Can OR ( or ||) be used with IF statements in PHP without complications or is it just generally better to use Switches?

I will give two examples and then ask this more principle based.

Do both of the script examples below essentially mean the same thing in PHP as they do in English?

EX1:

```php

If ($var == "02345" || "023645" || "3256"){
 domycommand1()
}

```

EX2:

```php
If ($var == "02345" ||$var == "023645" || $var == "3256"){
 domycommand1()
}

```

Does this quote apply to PHP syntax?

> [FONT=monospace]If $var = 026468 or 123457 Then[/FONT]

This does not mean “If $var = 026468 or 123457” (even though that’s what it looks like). It really means “If $var is equal to 026468, or 123457 is a non-zero number”. By using the OR, you have created two separate conditions. If either condition, or both, is true, the code will be executed. You simply cannot use OR to compare a single variable to a set of values. That’s just the way it works.

Assuming that $var was not equal to 026468, the above statement might look like this after AutoIt is done processing:

[FONT=monospace]If FALSE or TRUE Then[/FONT]

> **[Best way to do ORs](https://www.autoitscript.com/forum/topic/44456-best-way-to-do-ors/#comment-331546)**
>
> I don't really know how to search examples of ORs in the forums (seeing as OR is only two chrs long)I'm not sure I have the syntax correct, also it looks convoluted.If $lineArray\[1\] = 026468 OR 123457 OR 462134 OR 45342725 OR 22316 OR 7004689 OR...
