March 2011
Beginner to intermediate
300 pages
7h 23m
English
It's time to flesh out the widget() function. This is the function that prints out the content that is visible on the frontend, and we want it to print out some random content. We are going to approach this in phases so that we can test it.
ContentRotator.php that generates some random content. For now, we're going to generate a random number. Later, we will pull up some random content from the database, but always keep things simple the first time around so you can test them. Add the following static function to ContentRotator.php:/**
Fetch and return a piece of random content
*/
static function get_random_content()
{
return rand(1, 1000000);
}This relies on PHP's rand() function, and ...
Read now
Unlock full access