jeudi 29 septembre 2016

PHP IF Statement - Two Variables Not Working

I have an IF statement and I need to check two variables, then execute the action if either of the variables are false.

I know I can use the OR (||) statement however for some reason it is not working. I am in the process of learning PHP so it's probably a syntax error on my behalf.

If I create the if statement with only one (either) variable, it works fine:

<?php if ($var1 == false) { do whatever...} ?>

However when I try to check two, neither of the variables seem to be checked. I have tried different syntax variations but nothing works:

<?php if (($var1 == false) || ($var2 == false)) { do whatever...} ?>
<?php if (($var1 == false) OR ($var2 == false)) { do whatever...} ?>
<?php if ($var1 == false || $var2 == false) { do whatever...} ?>
<?php if ($var1 == false OR $var2 == false) { do whatever...} ?>

Can someone please point out what my error is?

Thanks!

Aucun commentaire:

Enregistrer un commentaire