vendredi 2 novembre 2018

Why is good to check for "false" first in an if statement?

For example the following code tests for false first then truth. Is there any performance benefits or time saving doing this?

if (!touch('some_file.txt', $time)) {
    echo 'Whoops, something went wrong...';
} else {
    echo 'Touched file with success';
}

Aucun commentaire:

Enregistrer un commentaire