0

When there is an if statement like:

if (var1 == "test" || var2 == "test")

will PHP stop testing when var1 is already tested true and therefore not test var2? I know C# doesn't but im not too sure about PHP

bicycle
  • 8,235
  • 8
  • 49
  • 72

1 Answers1

4

Only if the specific operators short-circuit, which the boolean operators do.

Community
  • 1
  • 1
Ignacio Vazquez-Abrams
  • 740,318
  • 145
  • 1,296
  • 1,325
  • @ignacia Vazquez-Abrams so in this case since I'm using || when var1 is tested false, var2 won't get tested right? – bicycle Sep 25 '12 at 17:56
  • 1
    @Michael: When `var1 == 'test'` is `TRUE` it will stop, if it's `FALSE` it needs to test `var2 == 'test'`. – gen_Eric Sep 25 '12 at 17:58