This course will be retired on June 1, 2025.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
In this video we'll take the concepts we've learned to develop a daily exercise program. We'll use variables and conditionals to show us a different exercise each day.
Starter Code for Daily Exercises
// store each exercise in a string variable
$exercise1 = 'Display "Hello World!"';
$exercise2 = 'Convert Pounds to Kilograms';
$exercise3 = 'Convert Kilograms to Pounds';
$exercise4 = 'Convert Miles to Kilometers';
$exercise5 = 'Convert Kilometers to Miles';
$exercise6 = 'Month long string of the day';
$exercise7 = 'String of the day with levels';
// create a variable containing the day of the week
// use an if statement to test for the day of the week
// display the corresponding exercise string
Documentation
The date() function returns a string formatted according to the given format string.
'N' returns a numeric representation of the day of the week 1 (for Monday) through 7 (for Sunday)
To see all formatting options, visit the PHP Documentation for date().
Additional Practice
- Perform other conversions or mathematical computations.
- Add a skill level to your exercises and display an exercise by skill level as well as day.
- Create a quote of the day or
- Show a greeting based on the time of day.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up