-3

In this exemple, if the first conditions is matched, are the other one tested by the compilator ?

a = 10
if (a % 2 == 0 || a / 2 == 5 || a == 10)
   echo 'hello world'
Patrick W
  • 1,485
  • 4
  • 19
  • 27
j.y
  • 37
  • 3

1 Answers1

6

In logical or conditions are checked from left to right. If the left condition is true then remaining right conditions are not checked by the compiler.

bool condition_1 = true;
bool condition_2 = false;

if(condition_1 || condition_2) in this case condition_2 is not checked by compiler.

Mayur
  • 2,583
  • 16
  • 28