PHP Tip: Always Put Constants on the Left in Boolean Comparisons

This was a standard I enforced at my last company: Whenever you are doing a boolean check (such as an IF or WHILE), always place constants on the left side of the comparison. The following is BAD: // BAD if($user == LOGGED_IN) { The following is good: // GOOD if(LOGGED_IN == $user) { Why is […]