Verification: a143cc29221c9be0

Php boolean and or not

Содержание

Why doesn't it work?

Your conditional expression will always evaluate to TRUE regardless of the variable value.

if (($nowday == "thu"||"thu")) 

Case 1: When $nowday is thu:

1. (($nowday == "thu") || "thu") // precedence grouping
2. (TRUE || "thu")               // ("thu" == "thu") is TRUE
3. (TRUE || TRUE)                // because non-empty string evaluates to TRUE
4. (TRUE)  

Case 2: When $nowday is sat:

1. (($nowday == "sat") || "thu") // precedence grouping
2. (FALSE || "thu")              // ("thu" == "sat") is FALSE
3. (FALSE || TRUE)               // non-empty string evaluates to TRUE
4. (TRUE)