Hi, I write a Tic Tac Toe game and the excuted code part is like:
if((check_win($grid) == "X") && (check_empty($grid)) && (check_valid($grid)))
{
print("Player1:\t\t<b>" . $p1 . "</b>\t(X)<br>");
print("Player2:\t\t<b>" . $p2 . "</b>\t(O)<br>");
print("<br><b>Congraduations!\t\t\t" . $p1 . ", you win!</b>");
}
else if((check_win($grid) == "O") && (check_empty($grid)) && (check_valid($grid)))
{
print("Player1:\t\t<b>" . $p1 . "</b>\t(X)<br>");
print("Player2:\t\t<b>" . $p2 . "</b>\t(O)<br>");
print("<br><b>Congraduations!\t\t\t" . $p2 . ", you win!</b>");
}
else if((check_drawn($grid)) && (check_empty($grid)) && (check_valid($grid)))
{
print("Player1:\t\t<b>" . $p1 . "</b>\t(X)<br>");
print("Player2:\t\t<b>" . $p2 . "</b>\t(O)<br>");
print("<br><b>You are drawn, please try again!</b>");
}
else
{
print("<br><b>Your inputs are not correct, please try again!</b>");
}
But every time I load the page the final else state ment would appear, How to avoid that problem, thanks🙁