php(random chosen)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wonderaz
Forum Newbie
Posts: 2
Joined: Tue Jan 09, 2007 12:10 am

php(random chosen)

Post by wonderaz »

Hello

I have an PHP exercise question like below:


Write a XHTML document to that includes an anchor tag that calls a PHP document. Also write the called PHP document, which returns a randomly chosen greeting from a list of five different greetings. The greetings must be
stored as constant strings in the script. A random number between 0 and 4 can be computed with these lines:

#set the seed for mtrand with the number of microseconds
#since the last full second of the clock
mt_srand ((double) microtime() * 1000000);
$number = mtrand(0, 4 ); #computes a random integer 0-4

Can anyone give me some guidelines in solving this question.
I din't ask for full coding.
I want to try first, so i really need your ideas insolving this question.
Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It would appear your exercise is from a pretty old reference set. mt_srand() has no longer been needed to be called since PHP 4.2.

As for the meat of your question: An array is the likely intended storage.
Post Reply