PHP“IF条件”[关闭]

Example 1)

       if(5 == $brandId)
       {
       }

Example 2)

       if($brandId == 5)
       {
       }

can somebody please explain the difference between this two conditions

They work identically as you can say 5 == 4 + 1 or you can say 4 + 1 == 5. In that respect they are identical as both compute to true (as a boolean).

One reason to use example 1 is if you typo it, like if ($brandId = 5), then the $brandId will be overwritten with the value 5. I don't know any other differences between these two, I tend to use the latter (example 2), because I think its easier to read/understand.

In first condition you have 5 compared with value of $brandId, while in second condition you have $brandId value compared with 5.
It's only code style difference, because there is no difference (5 == 5)