- <html>
- <head>
- <title>switch 判斷式</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- </head>
- <body>
- <?php
- date_default_timezone_set("America/New_York"); //Asia/Taipei America/New_York Pacific/Honolulu Europe/London
- echo "現在時刻: ".date("D, F j, Y, H:i:s")."<p/>";
- switch(date("H"))
- {
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 10:
- case 11:
- echo "Good Morning!<p/>";
- break;
- case 12:
- case 13:
- case 14:
- case 15:
- case 16:
- echo "Good Afternoon!<p/>";
- break;
- case 17:
- case 18:
- case 19:
- case 20:
- echo "Good Evening!<p/>";
- break;
- default:
- echo "Good Night!<p/>";
- }
- ?>
- </body>
- </html>
複製代碼 |