Displays a random quote on a web page

Displays a random quote on a web page. Quotes are picked from a list that you define.

Create a page and call it ( random_quote.php ) or anything you like than add the php include code below to your page where you would like to show random quotes. Make sure your page where you will include it is also php file.


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

The code


<?php

/**

 * Add this line of code in your page:

 * <?php include "random_quote.php"; ?>

 */

$quotes[] = "This is a quote";

$quotes[] = "This is another";

$quotes[] = "quote 3";

$quotes[] = "quote 4";

$quotes[] = "quote 5";

$quotes[] = "quote 6";

srand ((double) microtime() * 1000000);

$randomquote rand(0,count($quotes)-1);

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

?> 

About Bulent

Yes, my name is Bulent. I am originally from Turkey but now reside in United Kingdom. I have been working as a designer for over 8 years and have been very fortunate to have worked on a wide variety of projects. I have recently developed one of the most succesfull recruitment portal for nearly a million Turkish speaking community in UK within few months we had reached to nearly 65,000 users and stil growing. Thank you for stopping by!

Leave a comment

You must be logged in to post a comment.