Time Greeting
Create a new php web page that displays a time dependent greeting to the user by doing the following:
Add html code to the file like you are creating an html page.
Add php tags to the body.
Create a variable called
$hour
and set it equal to a number between 0 and 23.Write an if/elseif/else statement that echoes:
- “Good Morning” if
$hour
is between 6 and 11 (inclusive) - “Good Afternoon” if
$hour
is between 12 and 17 (inclusive) - “Good Evening” if
$hour
is between 18 and 23 (inclusive) or if$hour
is between 0 and 5 (inclusive)
Note, you can do this with what you learned in the tutorial but it is a little easier with logical operators, which weren’t in the tutorial. Read the PHP logical operators documentation for help.
- “Good Morning” if
Test the code by changing the value of the
$hour
variable and reloading the page.To make the page use the actual time, replace the variable defintion line with the code:
$hour = intval(date('G', time()));
Submission
Please show your completed web page and source code to the instructor.