mardi 22 novembre 2016

PHP use result of as variable

Is it possible to use the result of an if with an OR statement as a variable for a function?

As example:

$a = true;
$b = false;

if ($a || $b) {
     $this->functionCall($a)
}

Other example:

$a = false;
$b = true;

if ($a || $b) {
    $this->functionCall($b)
}

Third and final exmaple:

$a = true;
$b = true;

if ($a || $b) {
    $this->functionCall($a, $b)
}

So I need to detect what variable is true and pass it as a paramater. Is this even possible?

Any helps is appreciated!

Many thanks in advance

Aucun commentaire:

Enregistrer un commentaire