Php false location able

Typically, a comparison with falseis performed as follows, where it falseis on the right side:

if(strpos($str, 'php') !== false) {
    // code
}

But I also noticed in different places falseon the left side:

if(false !== strpos($str, 'php')) {
    // code
}

As far as I understand, they are the same, why do some people put falseon the left side? Is there anything special about this, something I am missing?

+2
source share
2 answers

Inattentive developers came up with something

"Problem"

if ($var = false) { /* code */ }

Decision

if (false = $var) { /* code */ }

The latter will fail, and therefore, the developer sees that he misses more =, !... here

+4
source

, , Yoda. , , , = == .

, .

+3

All Articles