dimanche 3 mars 2019

If statement is true OR not false

I have two statements like this:

$ready = true;

if($ready === true) {
    echo "it's ready!";
}

And this:

$ready = true;

if($ready !== false) {
    echo "it's ready!";
}

I know those mean the same thing as === true and !== false is the same thing. I see people use the negation type (is not false or is not {something}). like this: https://stackoverflow.com/a/4366748/4357238

But what are the pros and cons of using one or the other? Are there any performance benefits? Any coding benefits? I would think it is confusing to use the negation type rather than the straight forward === true. Any input would be appreciated! thank you

Aucun commentaire:

Enregistrer un commentaire