vendredi 2 septembre 2016

Comparison order in PHP IF

I'm pretty sure that there is no difference between this

if ($value === true)

and this

if (true === $value)

For me it always seems confusing. I used to think that it's a 'bad unconventional style of new developers'. Furthermore, my boss told me never to do such a thing.

But today I was looking through Slim's source code, written by the guy who created PHP: The Right Way, and saw this (line 341).

if (true === $value) {
    $c['settings'] = array_merge_recursive($c['settings'], $name);
}

I'm sure a guy like Josh Lockhart wouldn't do something like this if it was considered a bad practice. So what's with this order? Is it some kind of an old tradition?

Aucun commentaire:

Enregistrer un commentaire