Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
21 lines (11 sloc) 1.17 KB

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:

  • Create an array of quotes, and then use PHP's built-in array_rand to select one of them.

  • Create an array of quotes, shuffle the array, and then pop the last element from the array as your selected quote.

  • 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.

  • 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.