dimanche 4 décembre 2016

How to write multiple variable if statement in php

So I have an if-statement and I am not sure how is the best way to write it. Or if there is a proper way of writing it. Can I just use && every time or should I separate them with more () or does it really matter, is there a difference in performance ect?

$a = 10;
$b = 20;
$c = 8;
$d = 25;
$e = "";
$f = "not blank";

// FIRST EXAMPLE
if (!empty($e) && !empty($f) && $a <= $c && $b <= $d)
{
    // do something here
}

OR

if ( (!empty($e) && !empty($f)) && ($a <= $c && $b <= $d))
{
    // do something here
}

Aucun commentaire:

Enregistrer un commentaire