<?php // 先依據時間設定好問候語 $mytime = date("G"); if ( $mytime >= 6 && $mytime <=10 ) $msg = "你好-早安"; if ( $mytime >=11 && $mytime <=14 ) $msg = "哈囉-午安"; if ( $mytime >=15 && $mytime <=16 ) $msg = "傍晚黃昏、再努力一下"; if ( $mytime >=17 && $mytime <=18 ) $msg = "下班回家請慢走"; if ( $mytime >=19 && $mytime <=21 ) $msg = "還在忙嘛?記得收拾收拾囉!"; if ( $mytime >=22 && $mytime <=23 ) $msg = "快去洗洗睡"; if ( $mytime <= 5 ) $msg = "睡睡睡zzZZ"; // 顯示問候語 echo $msg; ?>