0

Here is the expression:

else if((($p1win == TRUE) AND ($p2win == TRUE)) OR (($p1win == FALSE) AND ($p2win == FALSE))){

echo "<BR>INSIDE IF<BR> P1WIN: $p1win<BR> P2WIN: $p2win <BR>";}

Which outputs:

P1WIN: 1 P2WIN: 77

(The 77 is applied earlier to keep it from being NULL, I was having problems with that evaluating to FALSE before).

More info:

Earlier in the code I do:

      if(is_null($p1win)){ 
      $p1win = 77;
      }

      if(is_null($p2win)){
      $p2win = 77;
      }

As I said, I've been having trouble with a NULL result evaluating to FALSE. But this doesn't work either. Is there some way I can set p1 or p2 to neither true or false?

Also, using the strict comparison doesn't let any of the correct test cases through (if p1win and p2win are both 1 it doesn't enter the if).

  • 3
    `77` still counts as true value unless you use the strict `===` comparison. – mario Jun 17 '14 at 00:19
  • 1
    Why are you comparing numbers to booleans at first place? – zerkms Jun 17 '14 at 00:21
  • What are you trying to accomplish? What's the significance of the number 77? And are these variables *intended* to hold integers or booleans? – Wyzard Jun 17 '14 at 00:41
  • Can you format your code nicely, please? Both for you and for us. You'd want to put the conditional on its own function or span it across multiple lines to make it more readable. – Francisco Presencia Jun 17 '14 at 00:43
  • If you want to compare both values against `===1` then don't use `===TRUE`. – mario Jun 17 '14 at 00:43

0 Answers0