php“;或;不起作用
我快疯了。试着做一周的工作,比如周一到周五php“;或;不起作用,php,boolean,Php,Boolean,我快疯了。试着做一周的工作,比如周一到周五 if (($nowday == "thu"||"thu")) 当$nowday为sat时为真 if (($nowday == "thu")) 给假$今天仍然坐着。显然这是对的。为什么我会得到虚假的真实 我疯了吗?还是PHP中的or运算符不是| | 请原谅这个新手的问题,是的,我已经搜索了很长很长时间,是的,我花了一个多小时在这个700行多页的小问题上 需要帮忙吗 史蒂夫为什么不起作用? 无论变量值如何,条件表达式的计算结果始终为TRUE。 if
if (($nowday == "thu"||"thu"))
当$nowday为sat时为真
if (($nowday == "thu"))
给假$今天仍然坐着。显然这是对的。为什么我会得到虚假的真实
我疯了吗?还是PHP中的or运算符不是| |
请原谅这个新手的问题,是的,我已经搜索了很长很长时间,是的,我花了一个多小时在这个700行多页的小问题上
需要帮忙吗
史蒂夫为什么不起作用?
无论变量值如何,条件表达式的计算结果始终为TRUE
。
if (($nowday == "thu"||"thu"))
案例1:When$nowday
为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)
1. (($nowday == "sat") || "thu") // precedence grouping
2. (FALSE || "thu") // ("thu" == "sat") is FALSE
3. (FALSE || TRUE) // non-empty string evaluates to TRUE
4. (TRUE)
案例2:When$nowday
为sat
:
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)
1. (($nowday == "sat") || "thu") // precedence grouping
2. (FALSE || "thu") // ("thu" == "sat") is FALSE
3. (FALSE || TRUE) // non-empty string evaluates to TRUE
4. (TRUE)
如何解决这个问题?
如果您只是想检查$nowday
是否为thu
,那么为什么需要编写两次条件?只需使用以下命令:
if ($nowday == "thu")
如果您需要检查$nowday
是否为thu或sat
,您应该写:
if ($nowday == "thu" || $nowday == "sat")
或者,可以用括号分隔表达式。这样,您可以确定条件的求值顺序。如果它们没有用括号括起来,将根据以下公式进行计算:
如果要检查多天,则可以使用:
为什么不起作用?
无论变量值如何,条件表达式的计算结果始终为TRUE
。
if (($nowday == "thu"||"thu"))
案例1:When$nowday
为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)
1. (($nowday == "sat") || "thu") // precedence grouping
2. (FALSE || "thu") // ("thu" == "sat") is FALSE
3. (FALSE || TRUE) // non-empty string evaluates to TRUE
4. (TRUE)
案例2:When$nowday
为sat
:
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)
1. (($nowday == "sat") || "thu") // precedence grouping
2. (FALSE || "thu") // ("thu" == "sat") is FALSE
3. (FALSE || TRUE) // non-empty string evaluates to TRUE
4. (TRUE)
如何解决这个问题?
如果您只是想检查$nowday
是否为thu
,那么为什么需要编写两次条件?只需使用以下命令:
if ($nowday == "thu")
如果您需要检查$nowday
是否为thu或sat
,您应该写:
if ($nowday == "thu" || $nowday == "sat")
或者,可以用括号分隔表达式。这样,您可以确定条件的求值顺序。如果它们没有用括号括起来,将根据以下公式进行计算:
如果要检查多天,则可以使用:
为什么不起作用?
无论变量值如何,条件表达式的计算结果始终为TRUE
。
if (($nowday == "thu"||"thu"))
案例1:When$nowday
为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)
1. (($nowday == "sat") || "thu") // precedence grouping
2. (FALSE || "thu") // ("thu" == "sat") is FALSE
3. (FALSE || TRUE) // non-empty string evaluates to TRUE
4. (TRUE)
案例2:When$nowday
为sat
:
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)
1. (($nowday == "sat") || "thu") // precedence grouping
2. (FALSE || "thu") // ("thu" == "sat") is FALSE
3. (FALSE || TRUE) // non-empty string evaluates to TRUE
4. (TRUE)
如何解决这个问题?
如果您只是想检查$nowday
是否为thu
,那么为什么需要编写两次条件?只需使用以下命令:
if ($nowday == "thu")
如果您需要检查$nowday
是否为thu或sat
,您应该写:
if ($nowday == "thu" || $nowday == "sat")
或者,可以用括号分隔表达式。这样,您可以确定条件的求值顺序。如果它们没有用括号括起来,将根据以下公式进行计算:
如果要检查多天,则可以使用:
为什么不起作用?
无论变量值如何,条件表达式的计算结果始终为TRUE
。
if (($nowday == "thu"||"thu"))
案例1:When$nowday
为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)
1. (($nowday == "sat") || "thu") // precedence grouping
2. (FALSE || "thu") // ("thu" == "sat") is FALSE
3. (FALSE || TRUE) // non-empty string evaluates to TRUE
4. (TRUE)
案例2:When$nowday
为sat
:
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)
1. (($nowday == "sat") || "thu") // precedence grouping
2. (FALSE || "thu") // ("thu" == "sat") is FALSE
3. (FALSE || TRUE) // non-empty string evaluates to TRUE
4. (TRUE)
如何解决这个问题?
如果您只是想检查$nowday
是否为thu
,那么为什么需要编写两次条件?只需使用以下命令:
if ($nowday == "thu")
如果您需要检查$nowday
是否为thu或sat
,您应该写:
if ($nowday == "thu" || $nowday == "sat")
或者,可以用括号分隔表达式。这样,您可以确定条件的求值顺序。如果它们没有用括号括起来,将根据以下公式进行计算:
如果要检查多天,则可以使用:
表示如果$nowday==“thu”
或如果表示“thu”
if(“thu”)
总是TRUE
,因为字符串“thu”不是空的。这就是为什么条件语句返回TRUE
,并且总是返回TRUE
您应该这样编写您的条件语句:
if (($nowday == "thu"|| $nowday == "thu"))
但这可以简化为:
if ($nowday == "thu")
表示如果$nowday==“thu”
或如果表示“thu”
if(“thu”)
总是TRUE
,因为字符串“thu”不是空的。这就是为什么条件语句返回TRUE
,并且总是返回TRUE
您应该这样编写您的条件语句:
if (($nowday == "thu"|| $nowday == "thu"))
但这可以简化为:
if ($nowday == "thu")
表示如果$nowday==“thu”
或如果表示“thu”
if(“thu”)
总是TRUE
,因为字符串“thu”不是空的。这就是为什么条件语句返回TRUE
,并且总是返回TRUE
您应该这样编写您的条件语句:
if (($nowday == "thu"|| $nowday == "thu"))
但这可以简化为:
if ($nowday == "thu")
表示如果$nowday==“thu”
或如果表示“thu”
if(“thu”)
总是TRUE
,因为字符串“thu”不是空的。这就是为什么条件语句返回TRUE
,并且总是返回TRUE
您应该这样编写您的条件语句:
if (($nowday == "thu"|| $nowday == "thu"))
但这可以简化为:
if ($nowday == "thu")
你的第一个条件不合适。如果你做了if(1){echo'true';}
,这将是true
,这是同样的情况,因为它不会与任何东西相比。好吧,首先,伙计们(和姑娘们?)我很抱歉没有早点说谢谢。我也在梅拉宁待了很长时间,但是,你知道,事情一直在发生