Displaying Random quote in web pages

Displaying Random quote in web pages

DescriptionDisplays a random quote on a web page. Quotes are picked from a list that we define.

Sample code<?php

/**
* Add this line of code in your page:
* <?php include “random_quote.php”; ?>
*/

$quotes[] = “This is a quote1″;
$quotes[] = “This is a quote2″;
$quotes[] = “quote 3″;
$quotes[] = “quote 4″;
$quotes[] = “quote 5″;

srand ((double) microtime() * 1000000);
$randomquote = rand(0,count($quotes)-1);

echo “<p>” . $quotes[$randomquote] . “</p>”;

?>

 

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.