Reverse the Comparison Condition for Safety

Hey, its been a long time since I post anything on this blog but it’s a start.

Today I would like to add programming tips, we all know about condition and comparison especially the “equals to” that sometimes got written as assignment because of one less ‘=’ in the line.

Ups, we all got destroyed because of one less character..

To avoid this kind of problem, we could just reverse the position of the compared value with the variable into..

So, even if You accidentally missing one ‘=’ character the compiler will generate errors (at least in PHP) and not destroying the humanity.

Error : the humanity is saved, err.. I mean “FATAL ERROR┬ásyntax error, unexpected ‘=’ on line number x” will be shown if You type this in PHP language.

There You go, no need to thank Me because I also read it somewhere, I just post it here as a reminder for Myself.

Leave a Reply

Your email address will not be published. Required fields are marked *