Jul 20, 2008

Random Message Generator

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

Random Message Generator

Neutrality
Here comes another one of Inspired's "amazing" PHP scripts. This little script lets you display a random message every time the user visits that particular page. It's not really that useful, but it does make the page a bit more "dynamic".

CODE

$randMsg = array("Hi, welcome to my page!", "Hey you! Thanks for visiting!",
"Bonjour, mon ami!", "So, do you like the site?", "Come one, come all!");

$MsgNum = count($randMsg);
$MsgGenNum = floor(rand(MsgNum));

echo $randMsg[$msgGenNum];



You can edit those values in the array if you want. Add more if you so choose. Enjoy!

Reply

rejected
Very nice, could you set it to be code snippets? Like

CODE
$randMsg = array("<img src='1.gif'>", "<img src='2.gif'>",
"<img src='3.gif'>", "<img src='4.gif'>", "<img src='5.gif'>");

$MsgNum = count($randMsg);
$MsgGenNum = floor(rand(MsgNum));

echo $randMsg[$msgGenNum];

Reply

karlo
Before, I readed the PHP manual. And I didn't see the floor function. What's the floor function?

Reply

no9t9
@ rejected
yes, you can put random html code in there as well. that is how some people do random advertisment and banner rotation.

@karlo
i believe the floor function is simple to drop any decimals because he is using that
number as an index for an array. (an array can't have decimal index number)

Reply

ill
It could also be used to display Random Quotes, which is something a lot of E/N sites do!

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. random message - 9.37 hr back. (1)
  2. random message generator - 29.32 hr back. (1)
  3. php random message - 35.99 hr back. (1)
  4. display messages generator - 44.04 hr back. (1)
  5. random generator source code - 47.12 hr back. (1)
Similar Topics

Keywords : random message generator

  1. Imap Problem - i want to check if the message is not seen (1)
    i'd like to know which message i had not been seen, so i searched the manual and fid 2 flags
    says Unseen == 'U' || Recent == 'N' mean. but i don,t understand what does Unseen ==
    'U' || Recent == 'N' mean(what he mean by flags )? i want to check if the
    message is not seen, so how to do that? i tried CODE $inbox =
    @imap_open("{mail.mysite.com:110/pop3}",
    "".$_SESSION['SESSION_USER_NAME']."+".$_SESSION['S
    ESSION_MAIL_HOST']."", $_SESSION&...
  2. Just About Completed My Own Message Board Source. - This one looks nice! (10)
    I've finally completed my message board source code! This one is very nice, and it has
    many, many features. So if you can, please rate them and possibly register if you like this
    /wink.gif' border='0' style='vertical-align:middle' alt='wink.gif' /> http://subzer0.net/boards/ ...
  3. Dynamic Image / Signature Generator - a simple code to change text on an image (12)
    In search of dynamically changing quote, saying or all other types of text on an image I came across
    a code that I have modified to fit my initial usage. This procedure requires two files and short
    knowledge of PHP. If you are familiar with Trap17's sig rotation code you will understand this
    procedure very fast. Code 1: dynamic_sig.php (you can rename this to index.php and you'll see
    at the end why) Code 2: a simple text file named anything (I will call it name.txt ) Code 1
    CODE <?php header("Content-type: image/png"); �...
  4. How To Make A Random 7 Number Code? - (2)
  5. Form Generator - (9)
    I am making a form generator like the one trap17 uses to make the code for website requests. well i
    have everything set up, i studied the code from the trap17 generator and learned from it, then i
    tried to make my own, but when i click the generate button, the code isnt filled out. if you would
    like an example please visit my website at www.notapplicable.rifehost.com/forms/wrf.php the
    problem is that it doesnt fill in the the answers. can anyone help? i will put credits on the
    affilates page and on the gen pages. Here is my code: (this is the form) Website ...
  6. Forms, Text Files, And Php For A Signature Generator. - Help a little. (1)
    Hello everyone! I am in need of some code a for a signature generator I am making. I am using
    BuffaloHELP's code for the php file, now I am trying to improve that code by making a form in a
    html file that will have the user say what is on the sig! But now, I need help getting the form
    data that is posted by the user to get into that sig! There is a file, sig.txt, where that tells
    the php file what text will go on the sig. But how can I make the form data in the html file go into
    the text file so it will go onto the sig? You might want to read BuffaloHELP&...
  7. Display Random File In A Directory - how to display a random file from a set directory. (9)
    hi, could someone please help me with this? I have some files in a directory and i want to know how
    i can randomly display link/s to one or more of the files in my directory for download. But it must
    not at any time display index.php which is also in the directory with the downloads. Thanks in
    advance for any help given /unsure.gif" style="vertical-align:middle" emoid=":unsure:" border="0"
    alt="unsure.gif" />...
  8. Write Random Text To Image - PHP script help! (5)
    I'm trying to create a script that writes text to an image. CODE
    header("Content-type: image/png"); $_phrases = array( "Test 1",
    "Test 2", "Test 3", "Test 4", "etc." ); $_rand_phrase =
    $_phrases[rand(0,count($_phrases)-1)]; $_image =
    imagecreatefrompng("gmail.png"); $_user_width =
    imaagettfbbox(9,0,"tahoma.ttf",$_rand_phrase); $_x_value =
    (200-($user_width[2] + 113)); ...
  9. My Self-coded Message Boards - Rate them! (25)
    Alright, I used my great knowledge of PHP ( /tongue.gif' border='0' style='vertical-align:middle'
    alt='tongue.gif' /> ) to code my own message boards! http://subzer0.net/php . The script
    runs exceptionally fast and posting/leveling up works and most of the admin/mod features work. If
    you want to register, then you would be able to explore these features more. If you don't, then
    could you just rate them by the look of the index? >_> Please rate them from 1 to 10!...
  10. Generate Random Phrases - ...from a txt file (4)
    I have a question on how to generate random phrases (facts, quotes, etc) which the server will
    randomly pick from txt file. Normally, I would use SSI to accomplish this task, but I recently added
    a blog (Nucleus) to my site which uses PHP (.php file). So my question is, how can you display
    random phrases in which the server will pick from a specified text file? Thanks! I saw a
    thread very similar to my problem, but the code supplied by Inspired does not allow the server to
    select the phrase from a file. The only reason I want this is because I have over 100 quo...
  11. Php Form -fantastico Form Generator - Need overview re: How To use & setup (0)
    Hey Guys, Can anyone give me a quick overview on how to use the Fantastico FORM generator script in
    CPanel. Need to set up several forms for website user input. Specifically, HowTo: 1) compose the
    form ; 2)Where to put the form (ie. in which folder etc.); 3) how to link the form to buttons on my
    other webpages; 4) output the form contents to e-mail boxes. Looked/searched for info &/or a
    tutorial but can't find one. Anybody. Thanks RGPHNX...



Looking for random, message, generator

Searching Video's for random, message, generator
advertisement



Random Message Generator



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE