Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

operand comparison in Zend Framework source code

I've been looking through Zend Framework's source code and noticed that most (if not all) comparisons are done with the operands in the reverse order I would expect:

if ((false !== $request) {
    ...
}

instead of:

if (($request !== false) {
    ...
}

What is the reason for this convention?

like image 639
Josh Avatar asked Mar 03 '26 00:03

Josh


1 Answers

It's called a Left-Hand Comparison.

Basically, it's so that if you forget to put the second = in ==, it'll error rather change the value of the variable...

like image 88
ircmaxell Avatar answered Mar 04 '26 13:03

ircmaxell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!