How To Create A Random Message Generator Using PHP

In: General|Latest News|PHP Widgets|Software|Tech News|WAMPServer|php|weblog

13 Jun 2009


Objective: User gets a new message every time; he refreshes the page.

Requirements: Adobe Dreamweaver or any Open Source Editor like Amaya, Aptana Studio etc.

Code:

<?php

$thoughts = “WORK IS WORSHIP

AS YOU SOW, SO YOU REAP

BARKING DOG SELDOM BITE

KNOWLEDGE IS POWER

SHOOT FOR THE MOON, YOU WILL REACH THE STARS

AN APPLE A DAY KEEPS THE DOCTOR AWAY

I AM WHAT, I AM

TO ERR IS HUMAN, TO FORGIVE IS DIVINE

WHEN THE NIGHT IS DARKEST, THE DAWN IS NEAREST

THEY CONQUER WHO BELIEVE THEY CAN

NOTHING IS IMPOSSIBLE

TIME &amp; TIDE WAITS FOR NONE

THINK BEFORE YOU LEAP”;

$thoughts = explode(“\n”, $thoughts);

$chosen = $thoughts[mt_rand(0, count($thoughts)-1)];

print $chosen;

?>

4 Responses to How To Create A Random Message Generator Using PHP

Avatar

Tim

June 13th, 2009 at 18:50

Thank you! A great tutorial :)

Avatar

How To Create A Random Message Generator Using PHP « SachinKRaj – The Blog

June 13th, 2009 at 23:53

[...] How To Create A Random Message Generator Using PHP Article taken from Shubhamoy’s Blog [...]

Avatar

sid

June 15th, 2009 at 18:04

hey really cool article. hope your hits increase to infinity………………

Avatar

How To Create A Random Message Generator Using PHP | sachinkraj - weblog

June 20th, 2009 at 12:41

[...] PHP, Web Development Article taken from Shubhamoy’s Blog [...]

Comment Form