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:
If ($var == "02345" || "023645" || "3256"){
domycommand1()
}
EX2:
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]