3

Possible Duplicate:
PHP - and / or keywords

if($foo == 0 or $bar == 1 || $baz == 2)
{
    ...
}

Is it better to use "or" or || and is there any significant difference between them?

Community
  • 1
  • 1
reformed
  • 4,205
  • 10
  • 58
  • 83

1 Answers1

13

It's basically a matter of choice.

There is a difference however, when it comes to operand precedence:

if ( false && false || true ) // true

if ( false AND false || true ) // false

See it here in action: http://codepad.viper-7.com/zvFPzR

Joseph Silber
  • 205,539
  • 55
  • 352
  • 286
  • 5
    personally, I've grown accustom to just using || since that is universal in most languages. Not all languages allow `OR` – kennypu Jan 01 '13 at 01:08