如何在语句中使用OR函数

时间:2014-02-06 02:59:55

标签: php

我希望在周一至周五的09.00到16.59之间设置$a = 5

   $time = time()%86400;
   if( (date("D") == "Mon") || (date("D") == "Tue") || (date("D") == "Wed") || 
   (date("D") == "Thu") || (date("D") == "Fri") && $time >= 32400 && $time <= 61119){
        $a = 5;
    }

有&amp;&amp;时间在最后读?它是“Mon OR Tue OR Wed OR Thu OR Fri ......”和“Time ...”,还是“Fri AND Time”?

1 个答案:

答案 0 :(得分:1)

你很接近,你需要围绕OR的一组括号,但是稍微清楚一点的方法可能是:

if( in_array((date("D"), array("Mon","Tue","Wed","Thu","Fri"))
     && $time >= 32400 && $time <= 61119 ){

甚至:

!in_array((date("D"), array("Sat","Sun"))