Random quote tips (for P1)
A requirement of Project 1 is a simple PHP feature that displays a different quote each time the page is loaded.
Example seen here: http://p1.dwa15.com
If you're unfamiliar with PHP, the course PHP notes assigned in Week 2 will give you all the information you need to accomplish this task.
There are limitless approaches to this simple feature; here are some ideas:
- Generate a random number between 0 and the number of quotes you wish to have. Build an if/else construct (or switch statement) that will print different quotes depending on the random number chosen.
Create an array of quotes and generate a random number (using rand) that's between 0 and the length of the array. Use this random number to extract one of the elements of the array as your selected quote.
Create an array of quotes, and then use PHP's built-in array_rand to select one of them.
Your own approach...
Whatever approach you use, be sure to follow the practices described in the note set PHP and HTML when building Project 1.