dimanche 27 mars 2016

PHP performance difference conditions of if statement

Hey quick question anyone knows if there is any performance difference between these 2 codes (PHP-7):

public function isActive() : bool
{
    if ($cond1) {
        if ($cond2) {
            return true;
        }
    }

    return false;
}

and

public function isActive() : bool
{
    if ($cond1 && $cond2) {
        return true;
    }

    return false;
}

(Yes I know the variables are not defined, question is about the if statements not the variables)

I ask this question because I'm focusing on readability of my code, but at same time maintaining my performance the best I can.

Even if it is just a very tiny performance difference (e.g 0.000000001%) I still like to know the answer.

Aucun commentaire:

Enregistrer un commentaire