猿问

PHP时间判断语句

<?php 
判断:
6点到9点就调用 echo "/css/css1.css"
10点到14点就调用 echo "/css/css2.css"
15点到17点就调用 echo "/css/css3.css"
18点到21点就调用 echo "/css/css4.css"
22点到次日点就调用 echo "/css/css4.css"
?>

慕斯王
浏览 419回答 3
3回答

犯罪嫌疑人X

date_default_timezone_set('PRC');$hour = date('H',time());if($hour>6 && $hour<9){$css = "/css/css1.css";}elseif($hour>10 && $hour<14){$css = "/css/css2.css";}elseif($hour>15 && $hour<17){$css = "/css/css3.css";}elseif($hour>18 && $hour<21){$css = "/css/css4.css";}else{$css = "/css/css5.css";}echo "现在是{$hour}点,调用{$css}";echo "<link href=\"{$css}\" rel=\"stylesheet\" type=\"text/css\" />";

摇曳的蔷薇

date_default_timezone_set('PRC');$hour = date('H',time());if($hour>6 && $hour<9){$css = "/css/css1.css";}elseif($hour>10 && $hour<14){$css = "/css/css2.css";}elseif($hour>15 && $hour<17){$css = "/css/css3.css";}elseif($hour>18 && $hour<21){$css = "/css/css4.css";}else{$css = "/css/css5.css";}echo "现在是{$hour}点,调用{$css}";echo "<link href=\"{$css}\" rel=\"stylesheet\" type=\"text/css\" />";
随时随地看视频慕课网APP
我要回答