- <html>
- <head>
- <title>switch 判斷式</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- </head>
- <body>
- <?php
- date_default_timezone_set('Asia/Taipei'); //Asia/Taipei America/New_York Pacific/Honolulu Europe/London
- 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/>";
- }
- echo date('D, F j, Y, H:i:s A');
- ?>
- </body>
- </html>
複製代碼 |