jeudi 5 octobre 2017

php if 2 booleans are true

I can't understand why the last debugbar message is showing. Strangely enough $nest = 1, not true.

$nest = true;
$showcosts = false;

Debugbar::info($nest);
Debugbar::info($showcosts);
Debugbar::info("x" . $nest . "x");
Debugbar::info("x" . $showcosts . "x");

Debugbar::info($nest == true);
Debugbar::info($showcosts);

if ($showcosts && $nest) {

    Debugbar::info("this should never show");

}

returns this:

true
false
x1x
xfalsex
true
false
this should never show

I'd like the last debugbar message not to show as only one of the conditions in the if statement are true.

I'm using Laravel 5.4 with PHP 7.

Aucun commentaire:

Enregistrer un commentaire